QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#335096#837. Giant PenguinJryno1TL 240ms88036kbC++142.7kb2024-02-22 17:15:582024-02-22 17:15:59

Judging History

你现在查看的是最新测评结果

  • [2024-02-22 17:15:59]
  • 评测
  • 测评结果:TL
  • 用时:240ms
  • 内存:88036kb
  • [2024-02-22 17:15:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int> 
#define fi first
#define se second
#define mkp(x,y) make_pair(x,y)
const int maxn=2e5+10,inf=1e9;
int n,m,k;
vector<int>G[maxn],tr[maxn],ed[maxn];
int siz[maxn],root,vis[maxn],subt[maxn];
int tfa[maxn];//father of generated tree
int find(int x){return tfa[x]==x?x:tfa[x]=find(tfa[x]);}
pii E[maxn];
vector<pii> kdis[maxn];//the dis from u to key nodes(only parents,inclusive)
int mdis[maxn];//the minval from u to a mark node
int dis[maxn];//for shortest path
void gsiz(int x,int fat){
	siz[x]=1;
	for(auto v:tr[x]){
		if(v==fat||vis[v])continue;
		gsiz(v,x);
		siz[x]+=siz[v];
	}
}
void grt(int x,int fat,int tsiz,pii &mn){
	int msiz=tsiz-siz[x];
	for(auto v:tr[x]){
		if(v==fat||vis[v])continue;
		grt(v,x,tsiz,mn);
		msiz=max(msiz,siz[v]);
	}
	mn=min(mn,mkp(msiz,x));
}
vector<int>subnod;
int clev,lev[maxn];
void gsubtr(int x,int fat,int id){
	subt[x]=id,subnod.push_back(x);
	lev[x]=clev;
	for(auto v:tr[x]){
		if(v==fat||vis[v])continue;
		gsubtr(v,x,id);
	}
}
int gtree(int x){
	//get new root
	gsiz(x,0);
	pii b=mkp(inf,-1);
	grt(x,0,siz[x],b);
	int nrt=b.se,nid=0;
	//get subtrees
	clev++;
	subnod.clear();
	subnod.push_back(nrt);
	for(auto v:tr[nrt]){
		if(vis[v])continue;
		nid++,gsubtr(v,nrt,nid);
	}
	vector<int>ky;
	ky.push_back(nrt);
	for(auto u:subnod){
		if(u==nrt)continue;
		for(auto v:G[u]){
			if(vis[v]||v==nrt||subt[u]==subt[v]||lev[v]!=clev)continue;
			ky.push_back(min(u,v));
		}
	}
	//get shortest paths
	sort(ky.begin(),ky.end());
	for(int i=0;i<ky.size();i++){
		if(i&&ky[i-1]==ky[i])continue;
		int u=ky[i];
		for(auto v:subnod)dis[v]=1e9;
		dis[u]=0;
		queue<int>Q;
		Q.push(u);
		while(!Q.empty()){
			int now=Q.front();
			Q.pop();
			for(auto v:G[now]){
				if(vis[v]||dis[v]<=dis[now]+1)continue;
				dis[v]=dis[now]+1;
				Q.push(v);
			}
		}
		for(auto v:subnod)kdis[v].push_back(mkp(u,dis[v]));
	}
	//split
	vis[nrt]=1;
	for(auto v:tr[nrt]){
		if(vis[v])continue;
		ed[nrt].push_back(gtree(v));
	}
	return nrt;
}
int main(){
	cin.tie(0),cout.tie(0),ios::sync_with_stdio(false);
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		G[u].push_back(v),G[v].push_back(u);
		E[i]=mkp(u,v);
	}
	for(int i=1;i<=n;i++)tfa[i]=i,mdis[i]=1e9;
	for(int i=1;i<=m;i++){
		int u=find(E[i].fi),v=find(E[i].se);
		if(u!=v){
			tfa[u]=v;
			tr[u].push_back(v),tr[v].push_back(u);
		}
	}	
	root=gtree(1);
	int q;
	cin>>q;
	while(q--){
		int x,y;
		cin>>x>>y;
		if(x==1){
			for(auto s:kdis[y])mdis[s.fi]=min(mdis[s.fi],s.se);
		} else {
			int ans=1e9;
			for(auto s:kdis[y])ans=min(ans,mdis[s.fi]+s.se);
			cout<<ans<<"\n";
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 22400kb

input:

5 4 0
1 2
2 3
3 4
4 5
7
1 1
1 5
2 1
2 2
2 3
2 4
2 5

output:

0
1
2
1
0

result:

ok 5 number(s): "0 1 2 1 0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 22288kb

input:

5 6 2
1 2
2 3
1 3
3 4
4 5
3 5
3
1 1
2 4
2 5

output:

2
2

result:

ok 2 number(s): "2 2"

Test #3:

score: 0
Accepted
time: 24ms
memory: 22432kb

input:

100 99 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52...

output:

99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
99
98
97
9...

result:

ok 199968 numbers

Test #4:

score: 0
Accepted
time: 30ms
memory: 22324kb

input:

100 99 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61...

output:

1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
0
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 199966 numbers

Test #5:

score: 0
Accepted
time: 30ms
memory: 22448kb

input:

100 99 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
2 25
1 26
1 27
1 28
2 29
1 30
1 31
1 32
1 33
2 34
1 35
1 36
2 37
1 38
4 39
1 40
1 41
2 42
2 43
1 44
1 45
2 46
1 47
1 48
1 49
2 50
2 51
1 52
1 53
1 54
2 55
3 56
2 57
1 58
2 59
2 60
3 61...

output:

2
3
3
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
4
3
3
3
3
4
3
3
4
3
2
3
3
4
4
3
3
4
3
3
3
4
4
3
3
3
4
4
4
3
4
4
4
3
3
4
3
3
3
4
4
4
3
3
3
3
3
4
3
3
3
3
3
3
3
3
3
3
4
4
3
0
3
3
4
3
4
3
3
4
3
4
2
3
3
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
4
3
3
3
3
4
3
3
4
3
2
3
3
4
4
3
3
4
3
3
3
4
...

result:

ok 199964 numbers

Test #6:

score: 0
Accepted
time: 25ms
memory: 22424kb

input:

100 99 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
28 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
39 41
41 42
41 43
41 44
44 45
44 46
46 47
44 48
48 49
48 50
50 51
50 52
51...

output:

68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
42
40
39
38
37
36
35
34
33
32
31
32
30
31
31
29
30
30
31
28
29
27
28
26
29
25
24
23
24
22
25
26
21
22
23
20
19
20
18
17
18
16
15
14
16
13
14
15
12
16
11
10
9
10
8
16
7
6
5
6
7
4
7
8
9
10
11
3
10
2
1
0
68
67
66
65
64
...

result:

ok 199966 numbers

Test #7:

score: 0
Accepted
time: 25ms
memory: 22380kb

input:

100 102 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
...

output:

24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
37
36
35
34
33
32
31
30
29
28
27
26
25
26
27
28
29
30
31
32
33
34
35
36
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
1...

result:

ok 199973 numbers

Test #8:

score: 0
Accepted
time: 27ms
memory: 22612kb

input:

75 102 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 1
1 19
13 25
1 26
26 27
27 1
2 28
28 29
29 2
3 30
30 31
31 3
4 32
32 33
33 4
5 34
34 35
35 5
6 36
36 37
37 6
7 38
38 39
39 7
8 40
40 41
41 8
9 42
42 43
43 9
10 ...

output:

6
5
4
3
2
1
2
3
4
5
6
7
8
9
10
10
9
8
7
8
9
10
9
8
7
7
7
6
6
5
5
4
4
3
3
1
0
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
11
11
10
10
9
9
8
8
9
9
10
10
11
11
10
10
9
9
8
8
6
5
4
3
2
1
2
3
4
5
6
7
8
9
10
10
9
8
7
8
9
10
9
8
7
7
7
6
6
5
5
4
4
3
3
1
0
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
11
11
10
10
9
9
...

result:

ok 199971 numbers

Test #9:

score: 0
Accepted
time: 30ms
memory: 22660kb

input:

100 174 6
1 2
1 3
1 4
2 3
2 4
3 4
5 6
5 7
5 8
6 7
6 8
7 8
9 10
9 11
9 12
10 11
10 12
11 12
13 14
13 15
13 16
14 15
14 16
15 16
17 18
17 19
17 20
18 19
18 20
19 20
21 22
21 23
21 24
22 23
22 24
23 24
25 26
25 27
25 28
26 27
26 28
27 28
29 30
29 31
29 32
30 31
30 32
31 32
33 34
33 35
33 36
34 35
34 36...

output:

1
1
0
1
3
2
3
3
5
5
5
4
7
7
6
7
9
9
9
8
10
11
11
11
13
13
12
13
13
14
14
14
15
16
16
16
18
18
17
18
19
20
20
20
19
18
19
19
20
21
21
21
20
19
20
20
22
21
22
22
22
22
21
22
22
22
22
21
24
24
23
24
24
24
23
24
25
26
26
26
25
24
25
25
26
25
26
26
26
26
26
25
27
27
27
26
27
27
27
26
1
1
0
1
3
2
3
3
5
5
...

result:

ok 199981 numbers

Test #10:

score: 0
Accepted
time: 25ms
memory: 22328kb

input:

100 118 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 1
2 9
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 11
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 21
22 25
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 31
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 4...

output:

31
30
31
32
33
34
33
32
31
32
26
27
28
29
30
31
30
29
28
27
32
31
30
31
32
33
34
35
34
33
26
27
26
25
24
23
22
23
24
25
20
21
21
20
21
21
20
19
18
19
12
13
14
15
16
17
16
15
14
13
10
11
10
9
8
7
6
7
8
9
24
24
23
24
23
22
21
22
23
24
1
0
1
2
3
4
5
4
3
2
26
27
28
27
26
27
26
25
24
25
31
30
31
32
33
34...

result:

ok 199963 numbers

Test #11:

score: 0
Accepted
time: 22ms
memory: 22384kb

input:

100 119 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 1
2 5
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 11
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 21
26 30
22 24
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 31
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 5...

output:

1
2
3
4
3
4
3
2
1
0
9
8
7
6
5
6
7
8
9
10
8
9
10
10
9
8
8
7
6
7
13
12
11
10
11
12
13
14
15
14
13
14
15
16
15
16
17
16
15
14
17
16
15
16
15
14
13
14
15
16
20
19
18
17
18
19
19
18
19
20
17
17
18
18
17
16
15
14
15
16
18
19
20
19
18
17
18
17
16
17
21
22
23
24
25
24
23
22
21
20
1
2
3
4
3
4
3
2
1
0
9
8
7
6...

result:

ok 199976 numbers

Test #12:

score: 0
Accepted
time: 30ms
memory: 22600kb

input:

100 119 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 1
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 11
13 19
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 21
24 26
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 31
35 38
31 33
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48...

output:

3
2
1
0
1
2
3
4
5
4
10
10
9
9
8
7
6
7
8
9
11
12
12
11
11
10
9
8
9
10
15
16
15
14
13
12
11
12
13
14
17
16
15
14
13
12
13
14
15
16
21
21
20
20
19
18
17
18
19
20
21
22
23
22
21
20
19
18
19
20
23
22
21
22
23
24
23
22
23
24
27
26
25
24
23
24
25
26
27
27
28
29
30
31
32
33
32
31
30
29
3
2
1
0
1
2
3
4
5
4
1...

result:

ok 199969 numbers

Test #13:

score: 0
Accepted
time: 25ms
memory: 22444kb

input:

84 123 10
1 2
1 3
2 3
1 4
1 5
4 5
1 6
1 7
6 7
1 8
1 9
8 9
1 10
1 11
10 11
1 12
1 13
12 13
1 14
1 15
14 15
1 16
1 17
16 17
1 18
1 19
18 19
1 20
1 21
20 21
22 23
22 24
23 24
22 25
22 26
25 26
22 27
22 28
27 28
22 29
22 30
29 30
22 31
22 32
31 32
22 33
22 34
33 34
22 35
22 36
35 36
22 37
22 38
37 38
22...

output:

9
10
10
10
10
10
10
8
9
10
10
10
10
10
10
10
10
10
10
10
10
6
7
7
7
7
6
5
7
7
7
7
7
7
7
7
7
7
7
7
7
7
4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
3
4
5
5
5
5
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
0
2
2
9
10
10
10
10
10
10
8
9
10
10
10
10
10
10
10
10
10
10
10
10
6
7
7
7
7
6
5
7
7
7
7
7
7
7
7
7
7
7
7
7
7
4
5
5
5
5
5
...

result:

ok 199952 numbers

Test #14:

score: 0
Accepted
time: 22ms
memory: 22408kb

input:

100 132 2
1 2
2 3
1 3
3 4
4 5
5 6
4 6
6 7
7 8
8 9
7 9
9 10
10 11
11 12
10 12
12 13
13 14
14 15
13 15
15 16
16 17
17 18
16 18
18 19
19 20
20 21
19 21
21 22
22 23
23 24
22 24
24 25
25 26
26 27
25 27
27 28
28 29
29 30
28 30
30 31
31 32
32 33
31 33
33 34
34 35
35 36
34 36
36 37
37 38
38 39
37 39
39 40
4...

output:

66
66
65
64
64
63
62
62
61
60
60
59
58
58
57
56
56
55
54
54
53
52
52
51
50
50
49
48
48
47
46
46
45
44
44
43
42
42
41
40
40
39
38
38
37
36
36
35
34
34
33
32
32
31
30
30
29
28
28
27
26
26
25
24
24
23
22
22
21
20
20
19
18
18
17
16
16
15
14
14
13
12
12
11
10
10
9
8
8
7
6
6
5
4
4
3
2
2
1
0
66
66
65
64
64...

result:

ok 199967 numbers

Test #15:

score: 0
Accepted
time: 25ms
memory: 22600kb

input:

99 177 7
1 2
1 3
1 4
2 3
2 4
3 4
4 5
4 6
5 6
6 7
6 8
6 9
7 8
7 9
8 9
9 10
9 11
10 11
11 12
11 13
11 14
12 13
12 14
13 14
14 15
14 16
15 16
16 17
16 18
16 19
17 18
17 19
18 19
19 20
19 21
20 21
21 22
21 23
21 24
22 23
22 24
23 24
24 25
24 26
25 26
26 27
26 28
26 29
27 28
27 29
28 29
29 30
29 31
30 31...

output:

39
39
39
38
38
37
37
37
36
36
35
35
35
34
34
33
33
33
32
32
31
31
31
30
30
29
29
29
28
28
27
27
27
26
26
25
25
25
24
24
23
23
23
22
22
21
21
21
20
20
19
19
19
18
18
17
17
17
16
16
15
15
15
14
14
13
13
13
12
12
11
11
11
10
10
9
9
9
8
8
7
7
7
6
6
5
5
5
4
4
3
3
3
2
2
1
1
1
0
39
39
39
38
38
37
37
37
36
...

result:

ok 199961 numbers

Test #16:

score: 0
Accepted
time: 22ms
memory: 22540kb

input:

500 499 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
10...

result:

ok 199829 numbers

Test #17:

score: 0
Accepted
time: 26ms
memory: 22556kb

input:

500 499 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 6...

output:

1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 199831 numbers

Test #18:

score: 0
Accepted
time: 28ms
memory: 22588kb

input:

500 499 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 6...

output:

2
3
3
3
3
3
3
3
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
4
3
3
3
3
3
4
3
3
3
3
3
3
3
4
3
3
4
3
3
3
3
3
3
3
3
3
3
3
3
3
4
4
3
3
4
3
3
4
3
3
3
3
...

result:

ok 199828 numbers

Test #19:

score: 0
Accepted
time: 32ms
memory: 22464kb

input:

500 499 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
100...

result:

ok 199848 numbers

Test #20:

score: 0
Accepted
time: 19ms
memory: 22512kb

input:

500 502 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
...

output:

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
14...

result:

ok 199808 numbers

Test #21:

score: 0
Accepted
time: 38ms
memory: 22916kb

input:

375 502 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
...

output:

32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
34
35
36
37
38
39
40
41
42
43
44
45...

result:

ok 199813 numbers

Test #22:

score: 0
Accepted
time: 29ms
memory: 22840kb

input:

500 874 6
1 2
1 3
1 4
2 3
2 4
3 4
5 6
5 7
5 8
6 7
6 8
7 8
9 10
9 11
9 12
10 11
10 12
11 12
13 14
13 15
13 16
14 15
14 16
15 16
17 18
17 19
17 20
18 19
18 20
19 20
21 22
21 23
21 24
22 23
22 24
23 24
25 26
25 27
25 28
26 27
26 28
27 28
29 30
29 31
29 32
30 31
30 32
31 32
33 34
33 35
33 36
34 35
34 36...

output:

1
1
1
0
3
2
3
3
5
5
5
4
6
7
7
7
8
7
8
8
10
10
9
10
11
12
12
12
14
14
13
14
15
16
16
16
17
17
17
16
17
18
18
18
18
19
19
19
21
20
21
21
23
23
22
23
25
25
25
24
27
27
27
26
28
29
29
29
30
30
29
30
32
32
32
31
34
34
33
34
36
36
36
35
37
38
38
38
38
39
39
39
40
41
41
41
41
42
42
42
44
44
43
44
46
45
46
...

result:

ok 199834 numbers

Test #23:

score: 0
Accepted
time: 29ms
memory: 22728kb

input:

484 530 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 1
13 17
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 23
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

6
5
4
3
2
1
0
1
2
3
4
5
6
7
8
8
7
8
9
9
8
7
20
19
18
17
16
15
14
13
12
11
10
11
12
13
14
15
16
17
18
19
20
21
25
26
27
28
29
29
28
27
26
25
24
23
22
23
24
25
26
27
27
26
25
24
30
29
28
29
30
31
32
33
34
35
36
37
38
38
37
36
35
34
33
33
32
31
33
32
31
32
32
31
30
29
30
31
32
33
34
35
36
37
38
38
37
3...

result:

ok 199829 numbers

Test #24:

score: 0
Accepted
time: 29ms
memory: 22636kb

input:

500 594 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 1
5 7
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 11
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 21
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 31
33 40
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 4...

output:

43
42
43
44
45
46
46
46
45
44
40
39
38
39
40
41
42
43
42
41
40
41
40
39
38
37
36
37
38
39
45
46
45
44
43
42
41
42
43
44
32
33
34
35
36
35
34
33
32
31
38
37
36
35
36
37
38
39
40
39
37
36
35
34
33
32
33
34
35
36
38
39
40
39
38
37
36
35
36
37
32
33
33
34
35
36
36
35
34
33
45
45
44
43
42
41
42
43
44
45
...

result:

ok 199840 numbers

Test #25:

score: 0
Accepted
time: 31ms
memory: 22704kb

input:

500 518 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 1
21 23
15...

output:

23
24
23
22
21
20
19
18
17
16
15
14
13
12
11
11
10
9
8
7
6
6
5
4
3
2
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
41
42
43
44
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
47
46
45
44
43
42
43...

result:

ok 199833 numbers

Test #26:

score: 0
Accepted
time: 28ms
memory: 22808kb

input:

483 712 10
1 2
1 3
2 3
1 4
1 5
4 5
1 6
1 7
6 7
1 8
1 9
8 9
1 10
1 11
10 11
1 12
1 13
12 13
1 14
1 15
14 15
1 16
1 17
16 17
1 18
1 19
18 19
1 20
1 21
20 21
22 23
22 24
23 24
22 25
22 26
25 26
22 27
22 28
27 28
22 29
22 30
29 30
22 31
22 32
31 32
22 33
22 34
33 34
22 35
22 36
35 36
22 37
22 38
37 38
2...

output:

1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
0
4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
4
3
7
8
8
8
8
8
8
8
8
6
7
8
8
8
8
8
8
8
8
8
8
10
11
11
11
11
10
9
11
11
11
11
11
11
11
11
11
11
11
11
11
11
13
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
12
13
16
17
17
17
17
17
17
17
17
17
17
17
17
17
17
15
1...

result:

ok 199847 numbers

Test #27:

score: 0
Accepted
time: 31ms
memory: 22516kb

input:

500 665 2
1 2
2 3
1 3
3 4
4 5
5 6
4 6
6 7
7 8
8 9
7 9
9 10
10 11
11 12
10 12
12 13
13 14
14 15
13 15
15 16
16 17
17 18
16 18
18 19
19 20
20 21
19 21
21 22
22 23
23 24
22 24
24 25
25 26
26 27
25 27
27 28
28 29
29 30
28 30
30 31
31 32
32 33
31 33
33 34
34 35
35 36
34 36
36 37
37 38
38 39
37 39
39 40
4...

output:

333
333
332
331
331
330
329
329
328
327
327
326
325
325
324
323
323
322
321
321
320
319
319
318
317
317
316
315
315
314
313
313
312
311
311
310
309
309
308
307
307
306
305
305
304
303
303
302
301
301
300
299
299
298
297
297
296
295
295
294
293
293
292
291
291
290
289
289
288
287
287
286
285
285
284
...

result:

ok 199840 numbers

Test #28:

score: 0
Accepted
time: 32ms
memory: 22556kb

input:

499 897 7
1 2
1 3
1 4
2 3
2 4
3 4
4 5
4 6
5 6
6 7
6 8
6 9
7 8
7 9
8 9
9 10
9 11
10 11
11 12
11 13
11 14
12 13
12 14
13 14
14 15
14 16
15 16
16 17
16 18
16 19
17 18
17 19
18 19
19 20
19 21
20 21
21 22
21 23
21 24
22 23
22 24
23 24
24 25
24 26
25 26
26 27
26 28
26 29
27 28
27 29
28 29
29 30
29 31
30 3...

output:

1
1
0
1
2
2
3
3
3
4
4
5
5
5
6
6
7
7
7
8
8
9
9
9
10
10
11
11
11
12
12
13
13
13
14
14
15
15
15
16
16
17
17
17
18
18
19
19
19
20
20
21
21
21
22
22
23
23
23
24
24
25
25
25
26
26
27
27
27
28
28
29
29
29
30
30
31
31
31
32
32
33
33
33
34
34
35
35
35
36
36
37
37
37
38
38
39
39
39
40
40
41
41
41
42
42
43
43
...

result:

ok 199840 numbers

Test #29:

score: 0
Accepted
time: 31ms
memory: 22732kb

input:

1000 999 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
...

output:

999
998
997
996
995
994
993
992
991
990
989
988
987
986
985
984
983
982
981
980
979
978
977
976
975
974
973
972
971
970
969
968
967
966
965
964
963
962
961
960
959
958
957
956
955
954
953
952
951
950
949
948
947
946
945
944
943
942
941
940
939
938
937
936
935
934
933
932
931
930
929
928
927
926
925
...

result:

ok 199656 numbers

Test #30:

score: 0
Accepted
time: 31ms
memory: 22764kb

input:

1000 999 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 199657 numbers

Test #31:

score: 0
Accepted
time: 28ms
memory: 22852kb

input:

1000 999 0
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

2
3
3
3
3
3
3
3
3
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
...

result:

ok 199657 numbers

Test #32:

score: 0
Accepted
time: 28ms
memory: 22684kb

input:

1000 999 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
...

output:

676
675
674
673
672
671
670
669
668
667
666
665
664
663
662
661
660
659
658
657
656
655
654
653
652
651
650
649
648
647
646
645
644
643
642
641
640
639
638
637
636
635
634
633
632
631
630
629
628
627
626
625
624
623
622
621
620
619
618
617
616
615
614
613
612
611
610
609
608
607
606
605
604
603
602
...

result:

ok 199658 numbers

Test #33:

score: 0
Accepted
time: 24ms
memory: 22692kb

input:

1000 1002 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 5...

output:

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
...

result:

ok 199669 numbers

Test #34:

score: 0
Accepted
time: 56ms
memory: 24536kb

input:

750 1002 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52...

output:

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
...

result:

ok 199665 numbers

Test #35:

score: 0
Accepted
time: 32ms
memory: 22780kb

input:

1000 1749 6
1 2
1 3
1 4
2 3
2 4
3 4
5 6
5 7
5 8
6 7
6 8
7 8
9 10
9 11
9 12
10 11
10 12
11 12
13 14
13 15
13 16
14 15
14 16
15 16
17 18
17 19
17 20
18 19
18 20
19 20
21 22
21 23
21 24
22 23
22 24
23 24
25 26
25 27
25 28
26 27
26 28
27 28
29 30
29 31
29 32
30 31
30 32
31 32
33 34
33 35
33 36
34 35
34 ...

output:

316
316
316
315
314
314
313
314
312
312
312
311
311
310
311
311
309
309
309
308
307
306
307
307
306
306
306
305
305
304
305
305
303
302
303
303
301
301
301
300
298
299
299
299
297
297
297
296
295
295
295
294
293
292
293
293
290
291
291
291
289
288
289
289
287
286
287
287
285
285
284
285
283
283
282
...

result:

ok 199658 numbers

Test #36:

score: 0
Accepted
time: 29ms
memory: 22800kb

input:

961 1017 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 1
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

4
3
2
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
15
14
13
12
11
10
9
8
7
6
5
19
18
17
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
31
30
29
28
27
26
25
24
23
22
21
20
23
22
23
24
25
26
27
28
29
30
31
32
33
32
31
30
29
28
27
26
25
24
25
26
27
28
28
27
26
25
24
40
39
38
37
36
37
38
39
40
39
38
37
36
3...

result:

ok 199675 numbers

Test #37:

score: 0
Accepted
time: 32ms
memory: 23064kb

input:

1000 1207 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 1
6 10
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 11
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 21
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 31
32 37
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
5...

output:

86
85
84
85
86
87
88
89
88
87
82
83
84
85
86
87
86
85
84
83
78
79
80
81
82
83
82
81
80
79
84
83
84
83
82
81
82
83
84
85
78
77
78
79
80
80
79
80
79
79
73
74
75
76
75
74
73
74
73
72
70
71
72
73
72
71
70
69
68
69
68
69
68
67
66
66
65
66
67
67
68
68
67
66
65
64
65
66
66
67
65
64
63
64
65
66
67
66
65
66
...

result:

ok 199680 numbers

Test #38:

score: 0
Accepted
time: 32ms
memory: 22708kb

input:

1000 1021 6
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52...

output:

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
46
45
44
43
42
43
44
45
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
70
71
72
73
74
75
7...

result:

ok 199661 numbers

Test #39:

score: 0
Accepted
time: 25ms
memory: 22644kb

input:

987 1456 10
1 2
1 3
2 3
1 4
1 5
4 5
1 6
1 7
6 7
1 8
1 9
8 9
1 10
1 11
10 11
1 12
1 13
12 13
1 14
1 15
14 15
1 16
1 17
16 17
1 18
1 19
18 19
1 20
1 21
20 21
22 23
22 24
23 24
22 25
22 26
25 26
22 27
22 28
27 28
22 29
22 30
29 30
22 31
22 32
31 32
22 33
22 34
33 34
22 35
22 36
35 36
22 37
22 38
37 38
...

output:

1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
0
4
5
5
5
5
5
5
5
5
3
4
5
5
5
5
5
5
5
5
5
5
7
6
7
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
10
11
11
11
11
11
11
11
11
11
11
11
11
10
9
11
11
11
11
11
11
13
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
13
12
14
14
16
17
17
17
17
17
17
17
17
17
17
17
17
17
17
15
1...

result:

ok 199657 numbers

Test #40:

score: 0
Accepted
time: 22ms
memory: 22748kb

input:

1000 1332 2
1 2
2 3
1 3
3 4
4 5
5 6
4 6
6 7
7 8
8 9
7 9
9 10
10 11
11 12
10 12
12 13
13 14
14 15
13 15
15 16
16 17
17 18
16 18
18 19
19 20
20 21
19 21
21 22
22 23
23 24
22 24
24 25
25 26
26 27
25 27
27 28
28 29
29 30
28 30
30 31
31 32
32 33
31 33
33 34
34 35
35 36
34 36
36 37
37 38
38 39
37 39
39 40...

output:

0
1
1
2
3
3
4
5
5
6
7
7
8
9
9
10
11
11
12
13
13
14
15
15
16
17
17
18
19
19
20
21
21
22
23
23
24
25
25
26
27
27
28
29
29
30
31
31
32
33
33
34
35
35
36
37
37
38
39
39
40
41
41
42
43
43
44
45
45
46
47
47
48
49
49
50
51
51
52
53
53
54
55
55
56
57
57
58
59
59
60
61
61
62
63
63
64
65
65
66
67
67
68
69
69
...

result:

ok 199654 numbers

Test #41:

score: 0
Accepted
time: 26ms
memory: 22812kb

input:

999 1797 7
1 2
1 3
1 4
2 3
2 4
3 4
4 5
4 6
5 6
6 7
6 8
6 9
7 8
7 9
8 9
9 10
9 11
10 11
11 12
11 13
11 14
12 13
12 14
13 14
14 15
14 16
15 16
16 17
16 18
16 19
17 18
17 19
18 19
19 20
19 21
20 21
21 22
21 23
21 24
22 23
22 24
23 24
24 25
24 26
25 26
26 27
26 28
26 29
27 28
27 29
28 29
29 30
29 31
30 ...

output:

1
1
0
1
2
2
3
3
3
4
4
5
5
5
6
6
7
7
7
8
8
9
9
9
10
10
11
11
11
12
12
13
13
13
14
14
15
15
15
16
16
17
17
17
18
18
19
19
19
20
20
21
21
21
22
22
23
23
23
24
24
25
25
25
26
26
27
27
27
28
28
29
29
29
30
30
31
31
31
32
32
33
33
33
34
34
35
35
35
36
36
37
37
37
38
38
39
39
39
40
40
41
41
41
42
42
43
43
...

result:

ok 199648 numbers

Test #42:

score: 0
Accepted
time: 133ms
memory: 62132kb

input:

100000 99999 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

99999
99998
99997
99996
99995
99994
99993
99992
99991
99990
99989
99988
99987
99986
99985
99984
99983
99982
99981
99980
99979
99978
99977
99976
99975
99972
99971
99970
99969
99968
99967
99966
99965
99964
99963
99962
99960
99959
99958
99957
99956
99955
99954
99953
99952
99951
99950
99949
99948
99947
...

result:

ok 166390 numbers

Test #43:

score: 0
Accepted
time: 133ms
memory: 62256kb

input:

100000 99999 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

77976
77975
77973
77972
77971
77970
77969
77967
77966
77964
77963
77962
77961
77960
77959
77958
77957
77956
77955
77954
77952
77951
77950
77949
77948
77947
77946
77945
77944
77943
77941
77940
77938
77937
77935
77934
77933
77932
77931
77930
77929
77928
77927
77926
77925
77924
77923
77922
77921
77920
...

result:

ok 166848 numbers

Test #44:

score: 0
Accepted
time: 176ms
memory: 71720kb

input:

100000 99999 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

67349
67348
67347
67346
67345
67344
67343
67342
67341
67340
67339
67338
67337
67336
67335
67334
67333
67332
67331
67330
67329
67328
67327
67325
67324
67323
67322
67321
67320
67319
67318
67317
67315
67314
67313
67312
67311
67310
67309
67308
67307
67305
67304
67303
67302
67301
67300
67299
67298
67297
...

result:

ok 166688 numbers

Test #45:

score: 0
Accepted
time: 185ms
memory: 72312kb

input:

100000 99999 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

19118
19117
19116
19115
19114
19113
19112
19111
19110
19109
19108
19107
19106
19105
19104
19103
19101
19099
19098
19097
19096
19095
19094
19092
19091
19090
19089
19088
19087
19086
19085
19084
19083
19082
19081
19080
19079
19078
19077
19076
19075
19074
19073
19072
19071
19070
19069
19068
19067
19066
...

result:

ok 166619 numbers

Test #46:

score: 0
Accepted
time: 220ms
memory: 87528kb

input:

100000 174999 6
1 2
1 3
1 4
2 3
2 4
3 4
5 6
5 7
5 8
6 7
6 8
7 8
9 10
9 11
9 12
10 11
10 12
11 12
13 14
13 15
13 16
14 15
14 16
15 16
17 18
17 19
17 20
18 19
18 20
19 20
21 22
21 23
21 24
22 23
22 24
23 24
25 26
25 27
25 28
26 27
26 28
27 28
29 30
29 31
29 32
30 31
30 32
31 32
33 34
33 35
33 36
34 35...

output:

29592
29593
29593
29593
29590
29591
29591
29591
29589
29589
29588
29589
29587
29587
29587
29586
29585
29586
29586
29585
29582
29582
29582
29582
29579
29580
29580
29580
29577
29578
29578
29578
29577
29577
29576
29577
29575
29574
29575
29575
29573
29573
29572
29573
29571
29570
29571
29571
29569
29567
...

result:

ok 166575 numbers

Test #47:

score: 0
Accepted
time: 216ms
memory: 87020kb

input:

100000 174999 6
1 2
1 3
1 4
2 3
2 4
3 4
5 6
5 7
5 8
6 7
6 8
7 8
9 10
9 11
9 12
10 11
10 12
11 12
13 14
13 15
13 16
14 15
14 16
15 16
17 18
17 19
17 20
18 19
18 20
19 20
21 22
21 23
21 24
22 23
22 24
23 24
25 26
25 27
25 28
26 27
26 28
27 28
29 30
29 31
29 32
30 31
30 32
31 32
33 34
33 35
33 36
34 35...

output:

21667
21667
21666
21667
21664
21665
21665
21665
21663
21662
21663
21662
21661
21661
21660
21661
21659
21659
21659
21658
21658
21658
21658
21657
21655
21656
21655
21655
21653
21653
21653
21652
21652
21652
21652
21651
21651
21651
21651
21650
21649
21649
21648
21649
21647
21646
21647
21647
21646
21646
...

result:

ok 166947 numbers

Test #48:

score: 0
Accepted
time: 137ms
memory: 62240kb

input:

100000 99999 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

99999
99998
99996
99995
99994
99993
99992
99991
99990
99989
99988
99986
99983
99982
99980
99979
99978
99977
99976
99975
99974
99973
99972
99971
99970
99969
99968
99966
99964
99959
99958
99956
99955
99954
99953
99952
99951
99950
99949
99948
99947
99945
99943
99942
99941
99939
99938
99937
99936
99935
...

result:

ok 150164 numbers

Test #49:

score: 0
Accepted
time: 139ms
memory: 62256kb

input:

100000 99999 0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

42631
42630
42629
42627
42626
42625
42624
42623
42621
42620
42619
42618
42617
42616
42615
42614
42613
42611
42610
42609
42607
42606
42605
42604
42603
42601
42600
42599
42598
42597
42596
42595
42594
42592
42591
42590
42588
42587
42586
42585
42583
42582
42580
42579
42578
42577
42576
42575
42574
42571
...

result:

ok 149881 numbers

Test #50:

score: 0
Accepted
time: 240ms
memory: 88036kb

input:

100000 174999 6
1 2
1 3
1 4
2 3
2 4
3 4
5 6
5 7
5 8
6 7
6 8
7 8
9 10
9 11
9 12
10 11
10 12
11 12
13 14
13 15
13 16
14 15
14 16
15 16
17 18
17 19
17 20
18 19
18 20
19 20
21 22
21 23
21 24
22 23
22 24
23 24
25 26
25 27
25 28
26 27
26 28
27 28
29 30
29 31
29 32
30 31
30 32
31 32
33 34
33 35
33 36
34 35...

output:

1
1
1
0
2
3
3
3
5
5
5
4
7
7
6
7
8
9
9
9
11
9
10
10
12
10
11
11
12
11
12
12
13
12
12
11
12
12
12
12
14
13
12
13
15
15
15
14
16
16
15
15
17
16
17
16
18
18
17
18
20
20
19
20
22
22
20
21
22
22
21
22
24
24
24
23
25
25
25
24
26
27
27
27
29
28
29
29
31
31
30
30
31
32
32
32
34
34
34
33
35
36
36
36
37
36
37
...

result:

ok 149733 numbers

Test #51:

score: 0
Accepted
time: 234ms
memory: 87284kb

input:

100000 174999 6
1 2
1 3
1 4
2 3
2 4
3 4
5 6
5 7
5 8
6 7
6 8
7 8
9 10
9 11
9 12
10 11
10 12
11 12
13 14
13 15
13 16
14 15
14 16
15 16
17 18
17 19
17 20
18 19
18 20
19 20
21 22
21 23
21 24
22 23
22 24
23 24
25 26
25 27
25 28
26 27
26 28
27 28
29 30
29 31
29 32
30 31
30 32
31 32
33 34
33 35
33 36
34 35...

output:

5363
5364
5364
5364
5361
5362
5362
5362
5359
5360
5360
5360
5358
5357
5358
5358
5355
5356
5356
5356
5354
5353
5354
5354
5352
5352
5351
5352
5349
5350
5350
5349
5346
5347
5347
5347
5346
5345
5346
5346
5345
5345
5344
5345
5343
5342
5342
5341
5340
5340
5338
5339
5337
5337
5336
5337
5335
5334
5335
5335
...

result:

ok 150393 numbers

Test #52:

score: 0
Accepted
time: 155ms
memory: 67672kb

input:

100000 100002 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
...

output:

24999
24998
24997
24995
24994
24993
24992
24991
24990
24988
24987
24986
24985
24984
24983
24982
24981
24979
24978
24977
24976
24975
24974
24973
24971
24970
24969
24968
24965
24964
24963
24959
24958
24957
24956
24954
24953
24952
24951
24950
24949
24948
24947
24946
24945
24944
24943
24942
24941
24940
...

result:

ok 149856 numbers

Test #53:

score: 0
Accepted
time: 145ms
memory: 67684kb

input:

100000 100002 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
...

output:

1478
1476
1475
1474
1473
1472
1471
1470
1469
1468
1466
1465
1464
1463
1462
1461
1460
1459
1457
1456
1455
1454
1453
1452
1451
1450
1448
1446
1445
1444
1443
1442
1440
1439
1438
1437
1436
1435
1433
1432
1431
1430
1429
1427
1426
1425
1424
1423
1422
1421
1419
1418
1417
1416
1415
1414
1413
1412
1410
1409
...

result:

ok 150383 numbers

Test #54:

score: -100
Time Limit Exceeded

input:

75000 100002 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
5...

output:


result: