QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#95940#121. Bitaro's Partyeyiigjkn100 ✓544ms244648kbC++141.7kb2023-04-12 16:24:512023-04-12 16:24:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-12 16:24:52]
  • 评测
  • 测评结果:100
  • 用时:544ms
  • 内存:244648kb
  • [2023-04-12 16:24:51]
  • 提交

answer

# include <bits/stdc++.h>
using namespace std;
constexpr int S=300,INF=1e9;
int a[100010],g[100010];
struct Edge
{
	int u,v;
	bool operator<(const Edge &t)const{return v<t.v;}
}E[200010];
struct Node
{
	int u,w;
	Node(int u,int w):u(u),w(w){}
};
using vn=vector<Node>;
vn f[100010];
inline void chkmax(int &x,const int &y){x=max(x,y);}
vn add1(vn A)
{
	for(auto &i:A) i.w++;
	return A;
}
vn operator+(const vn &A,const vn &B)
{
	int sz1=A.size(),sz2=B.size(),p=0,q=0;
	static bool vis[100010];
	vn C;C.reserve(max(sz1,sz2));
	while(C.size()<S && (p<sz1 || q<sz2))
	{
		if(p<sz1 && vis[A[p].u]) p++;
		else if(q<sz2 && vis[B[q].u]) q++;
		else if(p<sz1 && (q>=sz2 || A[p].w>B[q].w)) C.push_back(A[p]),vis[A[p++].u]=1;
		else C.push_back(B[q]),vis[B[q++].u]=1;
	}
	for(auto &i:A) vis[i.u]=0;
	for(auto &i:B) vis[i.u]=0;
	return C;
}
int main()
{
	int n,m,q,sz,u;
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++) scanf("%d%d",&E[i].u,&E[i].v);
	sort(E+1,E+m+1);
	for(int i=1;i<=n;i++) f[i]={Node(i,0)};
	for(int i=1;i<=m;i++) f[E[i].v]=f[E[i].v]+add1(f[E[i].u]);
	while(q--)
	{
		scanf("%d%d",&u,&sz);
		for(int i=1;i<=sz;i++) scanf("%d",&a[i]);
		if(sz>=S)
		{
			memset(g+1,0,sizeof(int)*n);
			for(int i=1;i<=sz;i++) g[a[i]]=-INF;
			for(int i=1;i<=m && E[i].v<=u;i++) chkmax(g[E[i].v],g[E[i].u]+1);
			if(g[u]>=0) printf("%d\n",g[u]);
			else puts("-1");
		}
		else
		{
			int ans=-INF;
			static bool vis[100010];
			for(int i=1;i<=sz;i++) vis[a[i]]=1;
			for(auto &i:f[u])
				if(!vis[i.u])
				{
					ans=i.w;
					break;
				}
			for(int i=1;i<=sz;i++) vis[a[i]]=0;
			if(ans>=0) printf("%d\n",ans);
			else puts("-1");
		}
	}
	return 0;
}

详细

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 1ms
memory: 6820kb

input:

1 0 1
1 0

output:

0

result:

ok single line: '0'

Test #2:

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

input:

1 0 1
1 1 1

output:

-1

result:

ok single line: '-1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 6524kb

input:

2 1 1
1 2
1 2 1 2

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 3ms
memory: 6684kb

input:

2 1 1
1 2
1 1 1

output:

-1

result:

ok single line: '-1'

Test #5:

score: 0
Accepted
time: 5ms
memory: 7504kb

input:

1000 2000 1
66 427
211 505
213 674
56 131
180 883
127 167
228 262
42 50
386 688
346 943
170 396
127 150
169 192
253 706
96 497
141 277
317 711
792 802
244 469
24 702
135 252
31 764
52 95
701 900
473 832
510 691
14 474
158 488
422 491
228 897
318 622
195 548
479 626
525 728
53 109
133 854
392 416
34 ...

output:

12

result:

ok single line: '12'

Test #6:

score: 0
Accepted
time: 1ms
memory: 8452kb

input:

1000 2000 1
762 826
799 904
17 20
56 733
46 416
261 768
196 392
121 144
14 69
244 625
331 485
331 383
502 635
107 914
131 274
288 495
70 103
417 934
318 535
775 930
9 113
250 677
82 200
2 4
36 77
367 553
8 31
633 712
21 179
484 963
117 146
207 413
685 787
561 903
508 710
834 912
4 76
196 977
355 394...

output:

14

result:

ok single line: '14'

Test #7:

score: 0
Accepted
time: 1ms
memory: 7908kb

input:

1000 2000 1
86 222
107 710
207 983
80 929
4 5
685 963
758 769
228 274
34 35
14 26
614 786
383 679
41 62
125 522
619 851
175 359
253 492
127 182
27 367
111 221
170 453
519 612
137 191
254 301
53 148
214 824
31 374
402 795
25 26
177 461
301 614
574 798
82 104
137 625
86 575
32 364
37 183
131 270
113 6...

output:

2

result:

ok single line: '2'

Test #8:

score: 0
Accepted
time: 9ms
memory: 9000kb

input:

1000 2000 1
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:

181

result:

ok single line: '181'

Test #9:

score: 0
Accepted
time: 9ms
memory: 9736kb

input:

1000 2000 1
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:

627

result:

ok single line: '627'

Test #10:

score: 0
Accepted
time: 9ms
memory: 9448kb

input:

1000 2000 1
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:

72

result:

ok single line: '72'

Test #11:

score: 0
Accepted
time: 2ms
memory: 8908kb

input:

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

output:

9

result:

ok single line: '9'

Test #12:

score: 0
Accepted
time: 7ms
memory: 10012kb

input:

1000 2000 1
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
3 17
16 18
2 19
18 20
1 21
1 22
13 23
15 24
6 25
1 26
1 27
1 28
1 29
2 30
1 31
1 32
26 33
11 34
8 35
1 36
19 37
30 38
29 39
24 40
10 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
29 51
22 52
49 53
7 54
1 55
1 56
9 57
44...

output:

11

result:

ok single line: '11'

Test #13:

score: 0
Accepted
time: 8ms
memory: 8836kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #14:

score: 0
Accepted
time: 2ms
memory: 9048kb

input:

1000 2000 1
999 1000
998 1000
997 1000
996 1000
995 1000
994 1000
993 996
992 1000
991 994
990 992
989 996
988 998
987 995
986 990
985 991
984 985
983 987
982 988
981 984
980 988
979 987
978 980
977 981
976 986
975 976
974 983
973 975
972 981
971 972
970 974
969 970
968 972
967 969
966 972
965 968
9...

output:

-1

result:

ok single line: '-1'

Test #15:

score: 0
Accepted
time: 6ms
memory: 8848kb

input:

1000 2000 1
999 1000
998 1000
997 1000
996 1000
995 1000
994 1000
993 1000
992 1000
991 1000
990 1000
989 1000
988 1000
987 1000
986 998
985 1000
984 993
983 1000
982 1000
981 1000
980 988
979 1000
978 1000
977 1000
976 984
975 1000
974 1000
973 1000
972 1000
971 980
970 1000
969 989
968 1000
967 10...

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 3ms
memory: 9408kb

input:

1000 2000 1
999 1000
998 1000
997 1000
996 997
995 1000
994 998
993 1000
992 1000
991 992
990 992
989 994
988 996
987 993
986 990
985 995
984 991
983 991
982 992
981 982
980 986
979 981
978 984
977 981
976 986
975 979
974 981
973 981
972 982
971 980
970 979
969 972
968 970
967 970
966 975
965 969
96...

output:

165

result:

ok single line: '165'

Test #17:

score: 0
Accepted
time: 1ms
memory: 9468kb

input:

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

output:

74

result:

ok single line: '74'

Test #18:

score: 0
Accepted
time: 2ms
memory: 8260kb

input:

1000 2000 1
1 74
2 21
3 90
4 63
5 100
6 70
7 50
8 108
9 82
10 26
11 74
12 39
13 34
14 25
15 72
16 56
17 50
18 21
19 93
20 85
21 73
22 55
23 85
24 108
25 73
26 67
27 71
28 77
29 126
30 42
31 59
32 75
33 126
34 46
35 101
36 75
37 124
38 94
39 110
40 86
41 132
42 138
43 68
44 53
45 59
46 58
47 93
48 70...

output:

8

result:

ok single line: '8'

Test #19:

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

input:

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

output:

0

result:

ok single line: '0'

Subtask #2:

score: 7
Accepted

Dependency #1:

100%
Accepted

Test #20:

score: 7
Accepted
time: 334ms
memory: 10176kb

input:

1000 200000 1
180 799
43 141
111 439
23 207
84 833
346 930
693 731
3 15
231 879
75 118
63 286
82 988
14 149
786 929
296 474
113 462
771 797
407 497
413 624
12 15
137 249
65 115
208 228
117 141
324 437
246 574
329 410
350 800
444 580
418 964
237 544
173 475
19 39
197 352
480 686
42 884
339 557
370 47...

output:

395

result:

ok single line: '395'

Test #21:

score: 0
Accepted
time: 342ms
memory: 10072kb

input:

1000 200000 1
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:

286

result:

ok single line: '286'

Test #22:

score: 0
Accepted
time: 343ms
memory: 9840kb

input:

1000 200000 1
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
15 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
3 54
1 55
1 56
1 57
1 58
1 59
1 6...

output:

196

result:

ok single line: '196'

Test #23:

score: 0
Accepted
time: 379ms
memory: 10168kb

input:

1000 200000 1
999 1000
998 1000
997 1000
996 1000
995 1000
994 1000
993 1000
992 1000
991 1000
990 1000
989 1000
988 1000
987 1000
986 1000
985 1000
984 1000
983 1000
982 1000
981 1000
980 1000
979 1000
978 1000
977 1000
976 1000
975 1000
974 1000
973 1000
972 1000
971 1000
970 1000
969 1000
968 100...

output:

140

result:

ok single line: '140'

Test #24:

score: 0
Accepted
time: 444ms
memory: 199396kb

input:

100000 200000 1
33743 95024
2194 8454
5183 61615
1325 12578
20276 40081
41257 89273
3021 31316
13816 15631
6304 71909
35427 68479
1880 5185
14215 14875
11370 19817
67215 75366
6711 22104
57106 63907
14771 52069
37895 83415
25190 39472
2775 40247
9190 65004
50644 65994
3659 85855
31776 43448
6475 989...

output:

26

result:

ok single line: '26'

Test #25:

score: 0
Accepted
time: 450ms
memory: 205620kb

input:

100000 200000 1
3523 29489
16384 42918
3190 26896
5877 78115
45640 61114
43902 54810
3316 9078
1888 33800
11069 61498
2488 3354
92773 94234
22770 32966
35898 68609
41732 41853
55275 58200
63778 83754
10418 71483
16436 44380
31417 40481
8872 52581
23505 94636
55765 80221
7228 10371
54697 72129
55321 ...

output:

27

result:

ok single line: '27'

Test #26:

score: 0
Accepted
time: 478ms
memory: 205020kb

input:

100000 200000 1
16282 63949
34779 39529
17878 31054
34240 81506
66666 82147
16893 58200
26898 75788
55525 89538
31382 84574
314 27982
16514 16556
16743 78660
6829 10094
2838 28448
23052 38212
15144 19880
4373 16846
4917 41100
2065 3164
26054 44717
24614 89706
6714 8307
12364 42283
2838 15571
8510 27...

output:

-1

result:

ok single line: '-1'

Test #27:

score: 0
Accepted
time: 470ms
memory: 244260kb

input:

100000 200000 1
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:

55535

result:

ok single line: '55535'

Test #28:

score: 0
Accepted
time: 439ms
memory: 244368kb

input:

100000 200000 1
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:

59303

result:

ok single line: '59303'

Test #29:

score: 0
Accepted
time: 499ms
memory: 244360kb

input:

100000 200000 1
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:

31684

result:

ok single line: '31684'

Test #30:

score: 0
Accepted
time: 449ms
memory: 244340kb

input:

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

output:

692

result:

ok single line: '692'

Test #31:

score: 0
Accepted
time: 498ms
memory: 240228kb

input:

100000 200000 1
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
22 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
46 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
26 59...

output:

152

result:

ok single line: '152'

Test #32:

score: 0
Accepted
time: 498ms
memory: 244324kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #33:

score: 0
Accepted
time: 396ms
memory: 154544kb

input:

100000 200000 1
99999 100000
99998 100000
99997 100000
99996 100000
99995 99998
99994 100000
99993 99996
99992 99995
99991 99993
99990 99994
99989 99990
99988 99996
99987 99990
99986 99994
99985 99987
99984 99992
99983 99989
99982 99984
99981 99982
99980 99983
99979 99980
99978 99988
99977 99980
999...

output:

151

result:

ok single line: '151'

Test #34:

score: 0
Accepted
time: 380ms
memory: 135328kb

input:

100000 200000 1
99999 100000
99998 100000
99997 100000
99996 100000
99995 100000
99994 100000
99993 100000
99992 100000
99991 100000
99990 100000
99989 100000
99988 100000
99987 100000
99986 100000
99985 100000
99984 100000
99983 100000
99982 100000
99981 100000
99980 100000
99979 100000
99978 10000...

output:

60

result:

ok single line: '60'

Test #35:

score: 0
Accepted
time: 361ms
memory: 153360kb

input:

100000 200000 1
99999 100000
99998 100000
99997 100000
99996 100000
99995 99998
99994 100000
99993 100000
99992 99995
99991 99995
99990 99994
99989 99998
99988 99998
99987 99988
99986 99994
99985 99987
99984 99988
99983 99989
99982 99988
99981 99984
99980 99981
99979 99980
99978 99984
99977 99982
99...

output:

0

result:

ok single line: '0'

Test #36:

score: 0
Accepted
time: 389ms
memory: 202036kb

input:

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

output:

5833

result:

ok single line: '5833'

Test #37:

score: 0
Accepted
time: 413ms
memory: 190024kb

input:

100000 200000 1
1 863
2 49
3 587
4 239
5 149
6 834
7 227
8 739
9 31
10 910
11 843
12 909
13 469
14 571
15 915
16 817
17 355
18 399
19 705
20 432
21 798
22 595
23 973
24 288
25 699
26 787
27 510
28 896
29 286
30 765
31 780
32 766
33 743
34 808
35 139
36 38
37 1016
38 803
39 804
40 529
41 750
42 728
4...

output:

61

result:

ok single line: '61'

Test #38:

score: 0
Accepted
time: 414ms
memory: 202776kb

input:

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

output:

-1

result:

ok single line: '-1'

Subtask #3:

score: 86
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #39:

score: 86
Accepted
time: 465ms
memory: 200236kb

input:

100000 200000 100000
74040 81077
10075 77192
4167 83961
6357 10091
48911 49972
64254 92040
4703 14723
11456 22053
18940 70698
76356 95132
11150 15058
43813 99395
34762 84775
3889 96199
69856 81771
2216 12369
82025 99321
17607 41771
4008 14665
19596 50414
2519 48648
31365 58806
43855 50597
16875 8209...

output:

0
21
19
27
0
18
1
24
25
29
29
9
30
7
25
28
23
20
30
26
24
0
26
0
20
20
24
21
25
23
28
18
25
32
24
27
0
5
17
21
22
14
28
0
0
17
28
31
27
34
28
26
26
23
24
19
25
21
18
29
1
33
27
27
26
30
27
26
23
20
26
1
27
16
15
18
23
28
26
7
23
0
26
0
28
0
21
33
32
20
20
17
22
23
25
25
1
23
0
0
17
21
16
27
26
31
28...

result:

ok 100000 lines

Test #40:

score: 0
Accepted
time: 465ms
memory: 202896kb

input:

100000 200000 10000
75227 84466
13112 42732
51738 87607
10577 44557
40520 75357
985 26504
2947 41069
11242 45311
38311 69758
3939 40598
890 9010
9779 12398
38104 71743
982 69579
2772 45919
14027 63915
56066 63588
4247 5707
4323 20659
11957 15738
27348 46564
15885 23455
13449 21976
7225 29377
10955 3...

output:

31
34
29
0
31
28
20
0
35
32
2
38
22
0
34
28
24
36
1
29
1
36
33
0
16
0
28
35
30
25
38
0
23
26
0
24
24
12
23
35
35
29
27
34
25
0
0
18
20
24
29
29
25
0
25
22
34
21
32
29
19
21
0
21
0
14
0
1
29
26
34
0
12
0
31
32
19
26
38
33
0
0
30
25
33
3
33
26
27
37
27
33
34
36
0
1
31
34
21
13
25
24
30
1
22
0
16
0
28
...

result:

ok 10000 lines

Test #41:

score: 0
Accepted
time: 468ms
memory: 204220kb

input:

100000 200000 1000
14602 85035
19668 70385
7089 19409
19241 92558
14080 25682
23541 47432
19558 25894
678 718
391 1212
17560 47791
26199 55408
6748 54557
9230 10026
12163 99200
6207 12650
27849 46133
29203 41554
38084 50025
38454 48718
61518 90511
22423 29561
9247 39096
90714 99594
2912 7853
38287 6...

output:

0
15
32
0
34
3
34
6
38
28
0
0
31
30
25
39
23
31
1
31
31
1
21
23
29
28
0
35
36
0
29
0
29
30
26
35
27
40
16
32
3
37
24
23
24
37
32
29
33
36
32
0
0
26
24
30
27
0
22
25
24
33
21
29
38
16
19
0
37
0
27
28
32
32
14
34
28
30
33
1
22
27
0
0
22
32
26
20
25
20
28
30
38
27
19
29
31
35
28
30
37
29
27
15
1
0
34
3...

result:

ok 1000 lines

Test #42:

score: 0
Accepted
time: 409ms
memory: 204240kb

input:

100000 200000 100
79457 88426
9896 35927
27255 45300
34295 51312
13924 69539
28276 81895
14529 26843
20957 51320
81777 98717
17321 53247
10723 77381
2484 5243
32373 44565
18277 31410
31782 39053
56619 62084
28950 44417
9914 39664
44400 57264
820 1162
11551 85834
22357 29656
28654 32720
10829 88257
2...

output:

25
30
35
31
36
35
32
27
33
1
28
28
27
0
30
0
27
1
17
17
29
36
1
27
0
20
30
28
34
35
27
30
32
35
33
3
22
33
31
23
28
27
39
10
0
24
0
5
27
28
29
28
21
32
2
34
31
18
23
0
28
18
40
35
31
28
24
2
35
36
28
34
0
22
19
29
24
2
1
23
33
25
32
25
33
27
33
25
23
30
0
33
34
30
32
28
36
27
1
0

result:

ok 100 lines

Test #43:

score: 0
Accepted
time: 450ms
memory: 201524kb

input:

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

output:

5513
284
270
14765
0
5780
3280
3266
16824
2306
5218
1470
7166
6363
6562
15096
6970
0
921
350
281
8393
8670
1473
6886
17567
1264
1
8919
10003
17165
2602
6748
2925
10057
2039
3
353
275
0
13134
142
2
12437
9186
1021
6567
15173
1476
3950
760
7297
17894
1983
1566
3905
13025
3037
0
10220
694
13105
1394
27...

result:

ok 300 lines

Test #44:

score: 0
Accepted
time: 479ms
memory: 191476kb

input:

100000 200000 300
1 22
2 57
3 858
4 896
5 453
6 170
7 650
8 394
9 481
10 30
11 610
12 510
13 291
14 379
15 883
16 715
17 924
18 127
19 26
20 464
21 27
22 703
23 151
24 904
25 662
26 803
27 517
28 514
29 789
30 151
31 62
32 220
33 971
34 160
35 53
36 723
37 793
38 198
39 698
40 436
41 372
42 1011
43 ...

output:

6
62
91
64
2
95
82
2
12
82
195
0
202
75
0
0
22
64
27
41
27
91
31
7
129
30
54
181
0
1
3
154
12
4
28
0
0
0
148
23
13
52
94
0
164
19
0
73
31
0
90
29
10
0
176
35
114
26
6
2
0
100
99
0
44
6
10
44
13
20
124
17
3
43
178
197
85
0
21
68
12
19
0
16
116
28
1
0
85
195
31
42
117
56
82
7
24
101
0
47
86
7
117
34
6...

result:

ok 300 lines

Test #45:

score: 0
Accepted
time: 451ms
memory: 243780kb

input:

100000 200000 500
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:

3708
76706
72230
19926
14998
5639
56267
73846
47900
88791
33947
61077
56261
95673
13400
12377
3573
41032
94807
68894
56165
31026
62804
15311
46722
86128
11233
96370
41975
82074
67518
82079
28245
19071
51328
74428
25937
6850
32503
50932
80113
51519
78596
30841
58737
31324
30031
85216
8365
23926
19494...

result:

ok 500 lines

Test #46:

score: 0
Accepted
time: 405ms
memory: 203040kb

input:

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

output:

0
0
825
696
2293
0
2055
0
4133
0
893
0
9273
1526
112
17668
0
10144
4513
3495
13591
8362
2648
8970
1255
4494
2
181
350
7543
0
2212
1247
0
4452
6680
6483
9562
17579
11844
0
3777
1381
4400
0
11793
3230
246
0
5497
13418
9249
9108
0
5745
0
329
4172
8032
6614
14339
4623
9976
688
10664
3182
3152
1006
5863
...

result:

ok 500 lines

Test #47:

score: 0
Accepted
time: 397ms
memory: 187696kb

input:

100000 200000 500
1 874
2 909
3 998
4 648
5 573
6 78
7 798
8 266
9 705
10 14
11 466
12 241
13 94
14 172
15 998
16 796
17 169
18 560
19 411
20 975
21 499
22 268
23 763
24 752
25 949
26 611
27 229
28 842
29 91
30 261
31 537
32 677
33 818
34 740
35 448
36 697
37 448
38 389
39 961
40 895
41 61
42 453
43...

output:

31
31
22
113
66
7
71
1
67
105
56
8
45
47
50
2
29
0
135
168
64
9
0
19
42
28
41
113
224
22
96
6
117
155
17
0
0
19
0
25
141
77
6
148
51
199
101
109
5
0
53
126
104
182
10
38
146
57
88
10
201
140
76
1
97
0
25
2
31
51
8
122
18
53
121
75
73
24
15
17
105
23
34
0
48
1
27
7
0
9
6
114
137
32
1
6
45
5
0
55
160
...

result:

ok 500 lines

Test #48:

score: 0
Accepted
time: 497ms
memory: 244176kb

input:

100000 200000 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:

76929
29960
56738
49737
7270
63950
5643
2493
77841
49603

result:

ok 10 lines

Test #49:

score: 0
Accepted
time: 431ms
memory: 201740kb

input:

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

output:

-1
3426
289
-1
2379
9226
4
8268
5716
12090

result:

ok 10 lines

Test #50:

score: 0
Accepted
time: 422ms
memory: 189592kb

input:

100000 200000 10
1 743
2 337
3 155
4 816
5 748
6 442
7 371
8 586
9 545
10 14
11 891
12 120
13 797
14 109
15 40
16 201
17 421
18 73
19 98
20 198
21 267
22 33
23 310
24 584
25 586
26 35
27 373
28 1026
29 79
30 975
31 665
32 346
33 666
34 638
35 148
36 1017
37 332
38 212
39 526
40 954
41 1014
42 682
43...

output:

0
0
58
31
2
0
96
1
156
0

result:

ok 10 lines

Test #51:

score: 0
Accepted
time: 465ms
memory: 244136kb

input:

100000 200000 30
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:

78376
5816
32044
33906
67875
92396
17899
93286
4150
91062
89678
81473
30571
17891
2343
64120
15508
83194
48012
53357
86796
92995
90443
42156
52487
89957
36816
69825
18029
35139

result:

ok 30 lines

Test #52:

score: 0
Accepted
time: 434ms
memory: 202044kb

input:

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

output:

0
6186
16045
-1
4275
14241
771
116
4156
9467
5597
4516
13187
3
6096
15481
0
0
5529
2955
1733
1033
8757
5454
5858
2038
10324
6860
17362
2

result:

ok 30 lines

Test #53:

score: 0
Accepted
time: 428ms
memory: 189196kb

input:

100000 200000 30
1 595
2 189
3 295
4 568
5 868
6 350
7 519
8 458
9 769
10 998
11 747
12 851
13 600
14 902
15 157
16 50
17 88
18 610
19 483
20 149
21 739
22 870
23 922
24 712
25 73
26 347
27 85
28 522
29 633
30 949
31 86
32 631
33 579
34 466
35 305
36 723
37 933
38 995
39 285
40 509
41 207
42 112
43 ...

output:

2
-1
184
195
-1
52
160
125
140
1
32
0
106
101
16
102
36
110
18
77
51
7
122
0
100
19
25
83
7
28

result:

ok 30 lines

Test #54:

score: 0
Accepted
time: 521ms
memory: 243980kb

input:

100000 200000 100000
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...

output:

7352
11279
85655
20877
59893
25404
78763
75369
67558
82423
73581
5302
18223
15789
35031
35606
80710
28908
54134
66918
35779
53621
84798
85436
51123
78440
43381
38847
86451
80157
96510
24019
94178
63968
71345
73251
60325
54725
20565
70430
18460
92502
61348
41749
27717
93291
30440
65345
39226
24074
90...

result:

ok 100000 lines

Test #55:

score: 0
Accepted
time: 478ms
memory: 243988kb

input:

100000 200000 1000
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 5...

output:

27691
71213
91210
75729
34927
36696
96418
16688
85900
62964
24859
7534
66658
74539
36772
91870
1257
45412
98894
96121
1709
23519
90084
67234
5333
29059
21941
89472
9183
34856
93508
11639
17640
72467
16306
74624
37452
32076
10627
77212
82710
31621
71644
72725
28809
28850
93524
34278
33054
94476
67153...

result:

ok 1000 lines

Test #56:

score: 0
Accepted
time: 474ms
memory: 244220kb

input:

100000 200000 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:

57693
6408
21900
88802
63585
27734
14155
4478
83502
49353

result:

ok 10 lines

Test #57:

score: 0
Accepted
time: 377ms
memory: 9732kb

input:

1000 200000 100000
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 5...

output:

397
881
361
311
701
806
967
650
621
775
434
230
729
130
897
632
781
240
817
413
940
549
345
398
486
36
171
500
23
166
653
278
209
790
145
310
714
422
371
780
889
725
419
91
69
327
404
149
666
10
853
579
861
278
829
783
641
79
553
618
951
920
23
662
992
139
936
57
20
932
72
894
625
767
15
151
543
680...

result:

ok 100000 lines

Test #58:

score: 0
Accepted
time: 361ms
memory: 9916kb

input:

1000 200000 1000
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:

568
323
429
158
990
890
824
554
901
319
65
679
471
191
528
169
675
255
25
904
6
63
650
374
44
695
952
908
909
318
838
788
154
624
532
535
204
498
547
463
943
66
278
557
141
852
572
762
248
473
915
64
799
274
844
598
66
671
676
721
950
841
106
595
300
442
291
503
590
299
813
692
185
824
746
595
435
3...

result:

ok 1000 lines

Test #59:

score: 0
Accepted
time: 340ms
memory: 9700kb

input:

1000 200000 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...

output:

785
587
105
658
449
288
374
731
795
429

result:

ok 10 lines

Test #60:

score: 0
Accepted
time: 534ms
memory: 244384kb

input:

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

output:

9528
12174
11496
3672
2673
7633
13642
2521
11569
15166
8251
6190
7638
2341
11768
17672
4037
2527
9937
8018
5084
13295
17639
13220
9297
16701
3028
6774
2358
4086
16466
112
14916
11629
15237
2115
15756
16601
4178
16855
10213
488
16191
1420
7657
3463
2670
18112
12552
10642
8437
5510
1514
10980
9524
166...

result:

ok 100000 lines

Test #61:

score: 0
Accepted
time: 544ms
memory: 240652kb

input:

100000 200000 100000
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
20 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...

output:

34
110
83
203
186
174
50
105
218
26
191
216
196
119
223
201
165
206
91
137
78
201
197
117
52
140
211
204
148
207
185
67
173
91
103
105
38
214
14
227
203
46
51
26
179
17
45
188
109
206
46
206
209
137
29
148
171
67
184
85
146
131
226
100
114
200
208
18
36
74
91
57
129
179
204
87
94
87
38
228
148
79
47...

result:

ok 100000 lines

Test #62:

score: 0
Accepted
time: 468ms
memory: 243976kb

input:

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

output:

3155
5897
13111
7919
4245
1445
9851
2081
12741
137
10305
15762
17120
1080
16987
18235
6873
11692
2995
3651
1136
13953
3059
12678
3594
6842
3950
9740
6118
15587
2840
12630
1952
18251
9539
10346
7577
5966
16395
7250
9402
1182
3175
5685
10903
9636
12710
5714
3481
244
1727
3603
17493
5575
9919
14225
138...

result:

ok 1000 lines

Test #63:

score: 0
Accepted
time: 458ms
memory: 202852kb

input:

100000 200000 10
57358 91820
25366 63614
2728 74270
58903 99347
16741 19896
2710 2792
61693 87394
34967 71676
88414 93559
11100 19613
543 69293
4475 84494
2263 14038
52804 93500
1158 1554
2479 40387
192 46478
11810 35053
6708 36733
2371 33941
18238 86926
42126 56157
34772 48846
2225 3524
27256 61229...

output:

0
25
22
25
0
29
19
39
20
22

result:

ok 10 lines

Test #64:

score: 0
Accepted
time: 468ms
memory: 239336kb

input:

100000 200000 1000
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...

output:

123
202
213
226
41
88
38
149
188
197
152
2
200
67
179
176
218
101
228
142
101
87
184
220
86
130
48
93
98
208
110
167
201
140
197
16
19
56
85
57
222
190
171
115
109
117
154
131
134
90
155
27
218
176
139
137
41
221
228
108
191
117
23
134
126
213
73
65
17
77
142
225
86
49
141
220
28
123
39
152
167
93
7...

result:

ok 1000 lines

Test #65:

score: 0
Accepted
time: 428ms
memory: 244228kb

input:

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

output:

7535
14230
1674
9766
8497
1270
2805
4768
12518
2145

result:

ok 10 lines

Test #66:

score: 0
Accepted
time: 467ms
memory: 241008kb

input:

100000 200000 10
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
18 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
...

output:

141
69
139
182
182
192
106
180
147
167

result:

ok 10 lines

Test #67:

score: 0
Accepted
time: 374ms
memory: 10064kb

input:

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

output:

468
626
544
421
119
269
193
337
629
328
308
130
303
289
452
401
454
617
48
303
165
337
110
467
428
305
339
617
576
380
532
475
511
436
392
331
63
300
119
271
181
572
571
244
544
566
198
515
427
468
593
26
278
522
21
387
410
284
207
360
96
233
612
615
119
179
247
412
560
362
456
563
369
443
327
557
5...

result:

ok 100000 lines

Test #68:

score: 0
Accepted
time: 368ms
memory: 10016kb

input:

1000 200000 100000
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
33 42
1 43
1 44
1 45
1 46
1 47
22 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 ...

output:

304
184
40
290
454
499
536
511
186
453
494
363
452
547
434
538
220
580
465
411
557
285
345
391
319
520
497
409
183
395
246
395
229
425
363
460
525
493
214
400
257
335
194
349
443
417
566
357
201
554
227
436
546
251
567
500
303
547
170
120
573
238
583
526
270
206
239
542
284
346
555
477
381
532
364
1...

result:

ok 100000 lines

Test #69:

score: 0
Accepted
time: 359ms
memory: 9692kb

input:

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

output:

71
378
474
451
130
444
546
515
233
414
477
287
461
365
472
325
497
86
275
452
198
184
496
251
544
408
327
495
571
451
605
195
554
590
517
85
366
107
426
533
345
568
363
622
557
510
352
76
451
542
402
142
147
37
429
361
327
533
497
502
534
340
593
361
581
530
288
107
615
286
57
300
517
552
108
342
12...

result:

ok 1000 lines

Test #70:

score: 0
Accepted
time: 342ms
memory: 10160kb

input:

1000 200000 1000
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
4 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
35 56
1 57
1 58
1 59
...

output:

472
198
160
404
131
454
140
4
298
483
502
426
575
190
430
522
355
63
500
572
457
481
571
6
392
259
181
18
564
233
63
570
275
359
372
187
88
507
98
404
356
390
235
210
293
16
440
91
450
522
55
47
227
299
273
255
258
37
164
285
510
324
479
453
461
443
584
129
242
343
114
382
530
503
305
46
509
372
292...

result:

ok 1000 lines

Test #71:

score: 0
Accepted
time: 343ms
memory: 10060kb

input:

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

output:

131
212
328
163
523
359
558
518
563
462

result:

ok 10 lines

Test #72:

score: 0
Accepted
time: 342ms
memory: 10608kb

input:

1000 200000 10
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 6...

output:

548
322
218
503
116
435
302
421
366
461

result:

ok 10 lines

Test #73:

score: 0
Accepted
time: 389ms
memory: 154272kb

input:

100000 200000 100000
99999 100000
99998 100000
99997 100000
99996 100000
99995 100000
99994 99995
99993 99997
99992 99993
99991 99992
99990 100000
99989 99994
99988 99995
99987 99997
99986 99995
99985 99988
99984 99990
99983 99992
99982 99991
99981 99991
99980 99988
99979 99981
99978 99981
99977 999...

output:

14429
3
20
15882
2
0
44
13282
0
9611
10733
1
9746
1
0
2
10358
4388
2
3
0
7725
13552
3
1841
0
0
13818
2733
2
1
14496
0
1
9
13
2
6474
2927
5192
11951
13075
15727
3
3206
9963
2326
3192
432
15731
3
7267
9128
12158
4896
0
3
4740
0
3622
0
3748
0
479
6267
13063
0
1
2
12747
1
18116
9032
4118
0
0
9880
17177
...

result:

ok 100000 lines

Test #74:

score: 0
Accepted
time: 342ms
memory: 134372kb

input:

100000 200000 100000
99999 100000
99998 100000
99997 100000
99996 100000
99995 100000
99994 100000
99993 100000
99992 100000
99991 100000
99990 100000
99989 100000
99988 100000
99987 100000
99986 100000
99985 100000
99984 100000
99983 100000
99982 100000
99981 100000
99980 100000
99979 100000
99978 ...

output:

0
3
85
89
6
50
222
0
102
3
0
10
53
74
8
219
171
129
197
91
3
182
198
186
212
231
155
2
8
110
0
72
0
119
2
2
0
187
6
101
40
232
193
15
0
0
0
0
35
10
51
38
204
15
84
99
141
192
1
42
192
0
170
63
4
12
3
50
177
7
3
12
82
0
0
226
0
202
42
2
0
93
40
113
215
153
1
216
0
1
53
0
5
0
58
0
60
48
126
0
71
89
62...

result:

ok 100000 lines

Test #75:

score: 0
Accepted
time: 363ms
memory: 153120kb

input:

100000 200000 1000
99999 100000
99998 100000
99997 100000
99996 100000
99995 99996
99994 99995
99993 100000
99992 99999
99991 99994
99990 99996
99989 99991
99988 99998
99987 99990
99986 99988
99985 99994
99984 99991
99983 99992
99982 99992
99981 99986
99980 99981
99979 99989
99978 99984
99977 99984
...

output:

9531
5
2436
6604
0
1
6519
1
12653
0
11180
15065
7701
1372
2
1
4
10760
2
0
4
4999
14738
0
14274
1
0
12714
1
1
3011
11387
5661
21
1959
3800
2
1
0
0
16861
16182
5773
0
2411
4
5446
16253
11136
0
2076
17170
8695
3016
3026
10496
2136
1294
18047
17088
1
12820
2867
0
13671
0
4
17450
13243
0
416
3
0
11727
0
...

result:

ok 1000 lines

Test #76:

score: 0
Accepted
time: 341ms
memory: 136688kb

input:

100000 200000 1000
99999 100000
99998 100000
99997 100000
99996 100000
99995 100000
99994 100000
99993 100000
99992 100000
99991 100000
99990 100000
99989 100000
99988 100000
99987 100000
99986 100000
99985 100000
99984 100000
99983 100000
99982 100000
99981 100000
99980 100000
99979 100000
99978 10...

output:

0
187
107
11
0
175
108
14
2
56
0
0
104
2
1
157
190
8
57
7
5
134
2
5
0
213
1
138
59
5
15
1
200
8
0
203
2
203
172
59
62
0
72
0
127
17
128
59
161
3
93
116
157
137
99
115
3
1
93
1
5
149
29
165
90
0
189
32
140
221
9
3
209
0
88
6
1
31
1
52
50
3
0
2
0
155
51
2
6
162
39
2
1
208
4
4
50
1
144
63
65
6
5
0
3
12...

result:

ok 1000 lines

Test #77:

score: 0
Accepted
time: 376ms
memory: 153984kb

input:

100000 200000 10
99999 100000
99998 100000
99997 100000
99996 100000
99995 99996
99994 99999
99993 99996
99992 99999
99991 99998
99990 99996
99989 99999
99988 99998
99987 99994
99986 99996
99985 99992
99984 99987
99983 99986
99982 99984
99981 99984
99980 99985
99979 99987
99978 99986
99977 99982
999...

output:

13450
5285
2
2283
13029
15756
9770
0
5914
11622

result:

ok 10 lines

Test #78:

score: 0
Accepted
time: 347ms
memory: 136568kb

input:

100000 200000 10
99999 100000
99998 100000
99997 100000
99996 100000
99995 100000
99994 100000
99993 100000
99992 100000
99991 100000
99990 100000
99989 100000
99988 100000
99987 100000
99986 100000
99985 100000
99984 100000
99983 100000
99982 100000
99981 100000
99980 100000
99979 100000
99978 1000...

output:

46
106
1
39
16
6
1
19
1
25

result:

ok 10 lines

Test #79:

score: 0
Accepted
time: 416ms
memory: 9680kb

input:

1000 200000 100000
999 1000
998 1000
997 1000
996 1000
995 996
994 999
993 1000
992 995
991 992
990 1000
989 997
988 995
987 995
986 989
985 987
984 990
983 985
982 989
981 989
980 988
979 983
978 979
977 986
976 978
975 983
974 981
973 983
972 982
971 981
970 977
969 976
968 978
967 976
966 976
965...

output:

19
187
7
537
596
271
376
107
383
303
417
173
141
226
293
295
591
297
166
510
400
499
540
523
327
351
375
217
131
486
109
422
183
408
226
464
385
83
15
332
433
62
10
105
190
349
319
151
425
221
382
187
503
220
3
347
322
51
127
20
175
349
309
399
243
443
93
300
634
289
558
48
463
472
613
598
78
186
59...

result:

ok 100000 lines

Test #80:

score: 0
Accepted
time: 404ms
memory: 9636kb

input:

1000 200000 100000
999 1000
998 1000
997 1000
996 1000
995 1000
994 1000
993 1000
992 1000
991 1000
990 1000
989 1000
988 1000
987 1000
986 1000
985 1000
984 1000
983 1000
982 1000
981 1000
980 1000
979 1000
978 1000
977 1000
976 1000
975 1000
974 1000
973 1000
972 1000
971 1000
970 1000
969 1000
96...

output:

369
267
498
152
234
24
230
221
228
268
198
384
417
199
39
140
398
7
257
98
139
327
260
54
16
9
345
366
40
281
287
34
482
86
40
133
246
64
137
333
288
293
526
499
275
88
75
296
283
389
61
133
168
33
420
523
298
544
9
238
503
123
118
396
82
515
333
127
230
505
139
40
510
141
201
538
393
554
47
545
69
...

result:

ok 100000 lines

Test #81:

score: 0
Accepted
time: 391ms
memory: 10268kb

input:

1000 200000 1000
999 1000
998 1000
997 1000
996 1000
995 996
994 1000
993 996
992 995
991 996
990 1000
989 995
988 995
987 989
986 987
985 995
984 994
983 989
982 991
981 987
980 988
979 987
978 979
977 984
976 978
975 982
974 977
973 975
972 979
971 977
970 976
969 972
968 970
967 969
966 969
965 9...

output:

184
491
462
329
341
598
279
408
137
426
176
66
227
17
139
159
234
453
176
352
86
58
513
22
461
522
326
224
338
97
77
313
559
410
294
577
17
65
10
50
269
38
210
192
257
115
73
71
364
129
2
101
522
2
421
56
3
307
425
254
434
490
426
333
94
43
358
273
501
456
61
34
605
357
65
60
214
174
421
611
541
366...

result:

ok 1000 lines

Test #82:

score: 0
Accepted
time: 385ms
memory: 9688kb

input:

1000 200000 1000
999 1000
998 1000
997 1000
996 1000
995 1000
994 1000
993 1000
992 1000
991 1000
990 1000
989 1000
988 1000
987 1000
986 1000
985 1000
984 1000
983 1000
982 1000
981 1000
980 1000
979 1000
978 1000
977 1000
976 1000
975 1000
974 1000
973 1000
972 1000
971 1000
970 1000
969 1000
968 ...

output:

171
111
293
180
536
25
13
290
521
50
251
346
0
23
222
67
111
219
456
262
402
502
97
234
57
566
293
480
43
334
213
142
367
322
3
550
523
485
227
302
293
322
204
51
192
428
302
513
238
451
23
320
191
559
163
261
421
557
520
174
217
419
498
228
589
46
438
79
526
108
103
347
282
232
183
107
147
164
145
...

result:

ok 1000 lines

Test #83:

score: 0
Accepted
time: 374ms
memory: 10600kb

input:

1000 200000 10
999 1000
998 1000
997 1000
996 998
995 1000
994 1000
993 995
992 1000
991 993
990 998
989 998
988 993
987 990
986 995
985 992
984 993
983 987
982 989
981 990
980 988
979 984
978 985
977 986
976 979
975 976
974 984
973 976
972 978
971 976
970 973
969 978
968 971
967 977
966 967
965 967...

output:

85
79
165
261
321
76
253
24
427
255

result:

ok 10 lines

Test #84:

score: 0
Accepted
time: 375ms
memory: 9748kb

input:

1000 200000 10
999 1000
998 1000
997 1000
996 1000
995 1000
994 1000
993 1000
992 1000
991 1000
990 1000
989 1000
988 1000
987 1000
986 1000
985 1000
984 1000
983 1000
982 1000
981 1000
980 1000
979 1000
978 1000
977 1000
976 1000
975 999
974 1000
973 1000
972 1000
971 1000
970 1000
969 1000
968 972...

output:

32
100
232
351
2
363
406
102
223
263

result:

ok 10 lines

Test #85:

score: 0
Accepted
time: 485ms
memory: 201180kb

input:

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

output:

192
826
0
1091
10019
6526
8219
2
1234
3500
15637
0
5664
4348
1168
7644
2582
72
15145
6361
8198
0
7420
1163
7858
3819
3809
1
12176
1
4101
6252
11577
745
9165
2343
5781
12357
0
13572
0
2019
9634
12387
982
18068
3747
0
0
1708
296
9206
1
893
1859
2084
4940
8105
9028
2067
480
5162
0
2096
2890
1985
86
153...

result:

ok 100000 lines

Test #86:

score: 0
Accepted
time: 467ms
memory: 189704kb

input:

100000 200000 100000
1 30
2 807
3 714
4 688
5 179
6 224
7 514
8 756
9 879
10 542
11 664
12 138
13 25
14 753
15 869
16 243
17 32
18 265
19 862
20 134
21 50
22 846
23 125
24 87
25 702
26 348
27 580
28 465
29 204
30 111
31 877
32 782
33 178
34 103
35 369
36 164
37 441
38 585
39 796
40 375
41 844
42 645...

output:

0
1
0
92
35
27
93
64
82
58
17
0
89
124
17
54
137
70
59
60
77
168
86
47
52
33
8
118
151
122
0
100
0
170
43
175
38
60
0
4
0
53
97
20
142
42
104
153
53
181
33
130
198
61
103
18
219
152
26
106
2
62
70
73
81
87
86
141
95
45
42
71
201
0
1
3
186
39
79
60
143
0
0
63
20
0
113
1
19
71
37
152
143
11
0
58
38
0
...

result:

ok 100000 lines

Test #87:

score: 0
Accepted
time: 443ms
memory: 203256kb

input:

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

output:

1042
1578
622
6244
3
10822
4638
1
825
0
6072
14903
9404
7134
3960
9180
2
1831
3585
3
1083
2077
11559
2057
8204
383
0
10095
1
0
6625
301
4232
10
3699
9412
4274
4948
1054
0
6585
10047
6084
1
3338
3387
0
8554
4923
8563
970
1
5246
0
5574
1
16441
4
850
0
4946
0
0
14507
13272
1
3615
3447
0
8365
3634
13965...

result:

ok 1000 lines

Test #88:

score: 0
Accepted
time: 405ms
memory: 189084kb

input:

100000 200000 1000
1 956
2 589
3 780
4 96
5 859
6 86
7 732
8 692
9 551
10 518
11 592
12 447
13 370
14 834
15 114
16 816
17 55
18 758
19 619
20 969
21 502
22 243
23 619
24 831
25 738
26 532
27 588
28 822
29 974
30 608
31 312
32 885
33 758
34 786
35 299
36 774
37 960
38 421
39 370
40 785
41 107
42 313...

output:

115
0
85
55
4
34
69
48
57
14
90
34
41
40
32
47
36
1
39
218
18
15
34
184
143
28
28
147
36
134
35
121
13
54
147
80
101
0
16
0
118
0
48
111
32
0
25
68
2
68
6
74
0
134
42
91
0
2
170
1
52
126
72
75
0
125
136
75
127
18
41
0
17
111
0
41
65
0
47
17
0
57
127
65
95
33
0
172
97
53
171
51
70
77
141
70
136
160
1...

result:

ok 1000 lines

Test #89:

score: 0
Accepted
time: 407ms
memory: 203148kb

input:

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

output:

3
2965
16232
1
2369
10131
9289
7552
7634
1887

result:

ok 10 lines

Test #90:

score: 0
Accepted
time: 438ms
memory: 190348kb

input:

100000 200000 10
1 882
2 659
3 854
4 440
5 299
6 132
7 662
8 676
9 103
10 526
11 520
12 477
13 836
14 546
15 688
16 44
17 197
18 282
19 319
20 789
21 546
22 745
23 25
24 767
25 749
26 60
27 292
28 297
29 594
30 685
31 346
32 635
33 411
34 643
35 564
36 250
37 216
38 746
39 127
40 1020
41 845
42 67
4...

output:

55
9
2
68
42
66
0
125
1
68

result:

ok 10 lines

Test #91:

score: 0
Accepted
time: 373ms
memory: 9704kb

input:

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

output:

483
153
640
531
77
504
120
419
322
609
638
644
358
259
639
512
574
238
338
437
373
432
513
404
648
612
514
586
369
640
636
276
405
464
351
461
25
542
418
193
249
436
47
313
630
516
461
426
181
490
522
461
462
609
476
468
637
284
522
370
31
579
272
206
344
226
182
502
583
363
189
333
30
437
402
596
4...

result:

ok 100000 lines

Test #92:

score: 0
Accepted
time: 371ms
memory: 9732kb

input:

1000 200000 100000
1 809
2 17
3 921
4 496
5 18
6 322
7 289
8 476
9 415
10 518
11 33
12 434
13 65
14 599
15 556
16 621
17 795
18 83
19 538
20 412
21 206
22 930
23 982
24 935
25 893
26 132
27 292
28 526
29 522
30 942
31 696
32 530
33 750
34 64
35 831
36 670
37 716
38 1000
39 389
40 304
41 520
42 662
4...

output:

354
71
288
557
461
563
310
450
159
522
188
316
405
473
490
452
534
244
439
43
388
425
540
534
441
401
310
113
261
498
23
385
324
540
175
582
502
432
242
564
20
387
516
566
384
122
419
121
217
105
151
317
31
314
485
440
203
272
555
233
346
511
303
539
537
410
483
35
479
500
391
365
139
574
196
226
17...

result:

ok 100000 lines

Test #93:

score: 0
Accepted
time: 400ms
memory: 10596kb

input:

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

output:

621
386
17
603
71
123
149
441
497
320
560
486
607
418
638
337
50
248
376
175
346
437
188
138
287
240
418
438
577
109
1
81
56
157
258
36
424
275
113
414
236
387
464
591
290
402
540
502
180
610
528
168
588
22
619
600
321
248
102
532
438
614
359
600
331
265
94
215
489
504
446
185
289
209
570
544
63
13
...

result:

ok 1000 lines

Test #94:

score: 0
Accepted
time: 360ms
memory: 9796kb

input:

1000 200000 100000
23 74
576 944
239 246
510 564
434 740
141 661
240 472
449 976
660 837
388 454
660 803
553 886
97 337
90 196
123 798
26 37
80 194
420 617
272 306
205 666
139 373
1 7
114 541
133 477
189 499
47 53
182 847
88 265
88 156
17 475
2 155
369 599
402 692
456 575
78 115
20 103
66 85
73 585
...

output:

407
305
279
396
458
582
142
421
386
235
124
224
593
447
177
551
582
450
62
509
286
314
219
315
507
386
179
516
447
417
223
115
175
552
164
352
65
566
14
203
118
394
117
532
483
209
90
273
141
463
224
509
440
479
589
543
252
180
343
272
552
370
579
334
270
392
251
43
50
440
388
88
418
29
506
286
19
2...

result:

ok 100000 lines

Test #95:

score: 0
Accepted
time: 347ms
memory: 10596kb

input:

1000 200000 1000
1 735
2 87
3 995
4 840
5 458
6 368
7 219
8 436
9 967
10 526
11 961
12 276
13 527
14 311
15 990
16 409
17 561
18 855
19 478
20 168
21 930
22 620
23 244
24 575
25 226
26 908
27 468
28 361
29 742
30 431
31 714
32 416
33 115
34 1000
35 992
36 898
37 84
38 991
39 408
40 741
41 678
42 552...

output:

304
357
535
10
305
117
555
183
526
469
531
477
19
54
463
263
155
41
532
420
587
407
417
291
251
501
325
28
263
275
263
180
207
465
528
57
252
584
266
216
256
206
395
568
109
210
106
507
456
241
510
495
524
141
484
560
413
513
512
533
68
473
305
382
566
27
341
520
322
278
352
551
13
510
548
426
500
2...

result:

ok 1000 lines

Test #96:

score: 0
Accepted
time: 339ms
memory: 9836kb

input:

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

output:

393
246
221
191
482
351
432
643
628
235

result:

ok 10 lines

Test #97:

score: 0
Accepted
time: 341ms
memory: 10052kb

input:

1000 200000 10
1 661
2 869
3 61
4 248
5 138
6 230
7 437
8 396
9 639
10 502
11 889
12 773
13 876
14 392
15 377
16 902
17 678
18 412
19 995
20 1000
21 382
22 77
23 882
24 255
25 478
26 300
27 940
28 678
29 340
30 512
31 431
32 207
33 327
34 356
35 546
36 928
37 61
38 555
39 206
40 643
41 449
42 132
43...

output:

536
588
592
352
138
569
352
303
509
395

result:

ok 10 lines

Test #98:

score: 0
Accepted
time: 468ms
memory: 244648kb

input:

100000 200000 5000
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 5...

output:

12275
66385
93233
79845
8376
57978
89338
18648
16620
59546
74747
42784
26844
36967
35241
21604
43685
92329
67344
50132
12827
42481
19040
89596
73580
71704
57238
32190
12609
44926
9706
47613
44390
98566
82612
97813
83815
67196
11184
14895
99816
98121
74918
21660
15443
77365
75181
7898
47924
43571
217...

result:

ok 5000 lines

Test #99:

score: 0
Accepted
time: 394ms
memory: 202700kb

input:

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

output:

6423
971
10558
0
1447
11950
0
0
11528
1431
1151
4661
5008
1
7413
5752
7509
459
819
5789
2574
4368
1047
2307
1724
1631
1475
4763
626
7330
1754
5496
3415
1152
16995
3
11381
668
7008
0
2061
173
3
9206
1076
15090
8650
1
8344
11153
9200
3327
659
918
13562
4
9542
9872
12061
10440
2
9259
3229
10583
902
286...

result:

ok 5000 lines

Test #100:

score: 0
Accepted
time: 421ms
memory: 188984kb

input:

100000 200000 5000
1 662
2 297
3 234
4 864
5 149
6 674
7 26
8 692
9 471
10 590
11 298
12 448
13 827
14 949
15 681
16 899
17 716
18 673
19 586
20 302
21 527
22 187
23 445
24 168
25 640
26 739
27 989
28 718
29 797
30 357
31 824
32 1000
33 321
34 802
35 293
36 987
37 121
38 337
39 769
40 268
41 833
42 ...

output:

29
96
117
113
28
119
0
2
40
1
0
70
92
1
102
64
69
23
97
172
37
14
39
131
30
5
31
111
105
41
165
0
99
17
96
56
0
149
2
0
50
0
107
0
42
89
21
0
1
44
0
122
2
92
10
114
64
161
0
1
0
89
210
11
0
0
84
31
76
0
9
2
4
0
0
12
49
44
170
0
50
0
65
0
61
101
1
45
98
18
12
0
96
0
0
0
121
10
103
174
97
53
1
1
2
50
...

result:

ok 5000 lines

Test #101:

score: 0
Accepted
time: 448ms
memory: 243788kb

input:

100000 200000 10000
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 ...

output:

68904
53874
61517
31652
19730
98482
52682
28532
99940
61138
85127
84959
70453
73924
17074
54511
4666
15814
60848
40703
70870
19625
67390
44994
7078
33952
72519
54486
80270
35285
14014
68730
9400
97706
25473
36480
55197
34806
13754
83913
12031
61423
58333
95081
83671
23668
7305
21731
60274
71628
6340...

result:

ok 10000 lines

Test #102:

score: 0
Accepted
time: 425ms
memory: 201416kb

input:

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

output:

0
4952
971
13919
10070
10052
2543
213
17183
8668
8678
6721
3316
2948
4514
0
11223
7005
1711
5078
10542
3718
6684
0
1795
12212
3737
4
0
1
9637
0
1434
0
9262
3008
11965
1014
0
5150
0
0
2418
6765
5
3016
2
7774
17366
9241
5167
11742
2779
11364
2678
3323
11109
3503
5794
132
5004
564
11526
4816
1985
1
349...

result:

ok 10000 lines

Test #103:

score: 0
Accepted
time: 449ms
memory: 188236kb

input:

100000 200000 10000
1 514
2 149
3 374
4 616
5 269
6 582
7 174
8 564
9 695
10 574
11 154
12 179
13 630
14 742
15 796
16 268
17 657
18 818
19 971
20 933
21 279
22 976
23 57
24 296
25 203
26 259
27 701
28 934
29 419
30 519
31 791
32 721
33 1008
34 70
35 248
36 409
37 72
38 802
39 778
40 87
41 88
42 611...

output:

17
58
184
152
72
4
105
1
53
107
120
18
58
111
18
19
64
213
114
52
69
69
1
9
98
9
45
1
129
1
1
162
189
0
2
0
0
1
11
227
55
126
1
68
1
31
39
15
90
188
3
38
166
0
0
197
15
109
136
49
76
123
143
25
59
109
46
0
164
50
0
2
0
210
221
91
120
0
51
17
50
59
56
49
100
22
14
0
24
69
0
12
0
1
115
19
136
0
76
214...

result:

ok 10000 lines

Test #104:

score: 0
Accepted
time: 492ms
memory: 243908kb

input:

100000 200000 2000
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 5...

output:

5361
80077
92203
67250
42852
93628
75292
48158
29217
34404
19827
2009
52121
51182
31330
52819
22890
6920
86348
5607
12610
48441
54070
47162
24786
61876
9223
94591
20892
67281
42129
83725
38471
99580
89496
10339
33357
7714
5049
10742
80296
80888
29018
21964
57995
61836
64766
81253
62620
54329
71150
1...

result:

ok 2000 lines

Test #105:

score: 0
Accepted
time: 415ms
memory: 203556kb

input:

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

output:

0
1098
4946
12370
1613
6526
3669
63
17311
11873
1872
4360
102
4582
821
2
11
209
0
541
5136
8095
0
6680
0
5005
44
0
5113
16263
1480
16443
3629
1
0
6699
3641
0
15287
5398
3127
934
2645
0
374
2118
1256
209
11579
1
1
0
683
2291
1137
6083
1
1163
9974
3919
12572
3610
3243
3897
1270
10070
3851
1699
5950
13...

result:

ok 2000 lines

Test #106:

score: 0
Accepted
time: 391ms
memory: 188444kb

input:

100000 200000 2000
1 367
2 577
3 515
4 16
5 428
6 818
7 731
8 396
9 559
10 574
11 595
12 774
13 333
14 507
15 946
16 681
17 69
18 503
19 962
20 520
21 407
22 853
23 708
24 856
25 716
26 579
27 341
28 718
29 255
30 565
31 535
32 1022
33 944
34 852
35 612
36 929
37 972
38 639
39 405
40 314
41 787
42 2...

output:

127
65
46
64
30
0
105
0
16
5
0
152
102
92
58
180
69
0
222
25
41
49
4
60
16
38
104
1
101
34
10
105
14
71
188
162
146
38
40
2
80
182
40
54
27
123
5
100
16
188
166
8
0
52
58
2
115
36
63
82
109
66
167
22
141
47
43
10
48
0
32
79
213
0
190
10
224
0
45
0
56
71
67
6
101
1
119
48
57
15
2
59
77
177
199
1
0
27...

result:

ok 2000 lines

Test #107:

score: 0
Accepted
time: 352ms
memory: 9708kb

input:

1000 200000 10000
113 272
90 955
445 485
362 364
75 226
609 653
587 841
50 575
89 165
195 357
218 265
338 415
24 550
821 938
134 214
163 248
98 466
198 335
207 606
946 970
338 467
137 315
16 287
561 734
114 349
114 998
19 112
328 560
353 408
134 816
78 212
1 16
383 916
550 593
19 406
371 449
388 429...

output:

586
293
313
424
403
542
404
571
90
288
349
442
597
370
272
298
340
491
594
328
281
542
104
471
71
518
434
577
25
472
471
555
543
513
511
480
462
594
66
347
222
375
555
348
192
460
164
405
507
388
366
189
308
360
441
374
550
575
181
125
459
509
161
533
118
345
539
410
461
6
487
524
513
196
344
584
47...

result:

ok 10000 lines

Test #108:

score: 0
Accepted
time: 345ms
memory: 9740kb

input:

1000 200000 1000
57 168
572 605
486 588
56 67
520 627
436 657
1 6
525 755
202 366
61 63
221 677
271 336
52 703
158 366
238 527
446 668
135 987
85 535
12 664
764 965
4 208
162 876
150 363
325 486
388 646
338 885
490 820
233 960
455 615
27 148
36 78
234 389
172 431
42 477
651 661
31 48
290 860
480 991...

output:

122
563
281
246
331
544
296
378
341
144
36
160
579
457
389
153
81
465
29
375
298
130
439
433
39
420
411
542
219
301
282
566
494
424
73
491
6
109
280
463
574
378
513
572
541
403
306
17
522
482
280
265
405
358
564
115
533
273
15
200
507
544
393
423
203
454
315
114
237
310
527
275
548
483
355
74
74
206...

result:

ok 1000 lines

Test #109:

score: 0
Accepted
time: 359ms
memory: 9680kb

input:

1000 200000 100
42 360
589 610
313 827
594 876
156 717
344 649
64 283
510 883
262 349
100 377
7 33
351 508
192 234
508 760
803 985
392 655
275 678
125 565
215 425
308 609
300 777
416 458
6 422
45 207
73 225
128 222
758 848
12 494
17 214
554 932
316 353
500 873
109 445
782 917
32 49
775 948
10 64
242...

output:

250
529
73
574
564
106
469
108
355
192
418
272
362
497
104
545
327
360
408
340
307
184
383
266
568
430
517
501
467
422
541
172
7
493
507
101
578
521
149
419
451
158
354
586
95
69
274
579
103
257
387
513
472
557
318
462
504
158
581
244
17
272
94
248
579
219
442
592
224
543
542
411
459
232
94
499
133
...

result:

ok 100 lines

Test #110:

score: 0
Accepted
time: 358ms
memory: 9732kb

input:

1000 200000 10
214 552
176 213
156 279
176 276
49 278
39 48
12 23
112 823
127 196
100 106
260 781
3 695
8 543
402 901
227 573
195 489
86 217
129 507
90 105
126 487
113 183
231 401
124 983
316 779
20 614
344 520
504 975
685 888
182 240
250 302
10 129
394 989
247 556
62 286
134 209
740 997
176 182
162...

output:

537
555
339
247
294
3
84
259
540
301

result:

ok 10 lines

Test #111:

score: 0
Accepted
time: 534ms
memory: 243780kb

input:

100000 200000 100000
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...

output:

70641
2025
91989
45236
84577
60242
2162
49121
53662
2553
46268
67258
2982
3074
25980
91516
6005
40827
63527
65527
57067
16196
8463
30018
9587
61063
16182
6594
16138
54204
78729
14053
61016
55885
15570
84277
31849
74807
97290
7433
79511
79519
83733
54065
55297
35965
45778
59630
51804
30203
92617
3620...

result:

ok 100000 lines

Test #112:

score: 0
Accepted
time: 456ms
memory: 243752kb

input:

100000 200000 1000
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 5...

output:

88378
2068
35465
4497
24959
36238
92579
79681
38199
23177
13765
27096
15442
57607
32183
59295
17380
83201
73684
33818
80873
65425
24089
4972
85282
10246
83839
74032
78905
87874
80811
98722
41704
56584
33827
53272
45717
96014
74693
87581
56587
54670
48674
65731
96772
11999
42278
48029
79531
39821
946...

result:

ok 1000 lines

Test #113:

score: 0
Accepted
time: 371ms
memory: 9732kb

input:

1000 200000 100000
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 5...

output:

889
599
534
239
210
564
717
865
942
50
274
899
690
210
152
335
686
310
710
565
172
948
866
177
482
120
977
519
926
991
368
284
6
503
891
560
769
646
834
529
680
471
581
152
111
129
426
4
788
691
785
892
525
591
278
990
756
960
41
105
517
136
584
248
765
400
139
828
976
255
3
184
850
36
112
118
41
50...

result:

ok 100000 lines

Test #114:

score: 0
Accepted
time: 362ms
memory: 9736kb

input:

1000 200000 1000
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:

466
149
664
750
684
336
414
807
642
895
131
398
258
398
544
721
13
247
193
454
350
506
344
493
28
477
648
876
802
283
750
28
388
453
101
152
521
-1
584
-1
216
456
136
-1
267
540
583
312
390
22
349
415
321
645
172
13
159
131
465
146
658
610
117
376
607
-1
638
259
495
-1
130
734
311
91
831
95
297
513
...

result:

ok 1000 lines

Test #115:

score: 0
Accepted
time: 478ms
memory: 201256kb

input:

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

output:

2898
11723
4109
533
2172
97
56
0
369
1664
11512
0
5778
922
6723
1466
12648
2286
3810
0
3529
8429
11946
14000
16086
2
7956
7994
7966
2778
12866
4872
109
1
12869
0
0
0
879
0
11755
0
8961
1709
13249
11206
1
0
1
143
3757
1593
0
323
5690
13284
3481
2266
7406
0
894
7440
10805
15719
6737
184
1
16597
6740
6...

result:

ok 100000 lines

Test #116:

score: 0
Accepted
time: 441ms
memory: 189904kb

input:

100000 200000 100000
1 390
2 567
3 338
4 744
5 483
6 720
7 138
8 370
9 81
10 982
11 976
12 420
13 681
14 151
15 927
16 763
17 968
18 167
19 1006
20 520
21 358
22 658
23 839
24 479
25 408
26 644
27 348
28 981
29 420
30 429
31 779
32 794
33 568
34 393
35 201
36 996
37 401
38 70
39 415
40 295
41 81
42 ...

output:

37
2
3
63
42
4
1
196
56
0
85
28
122
164
18
34
12
180
57
141
0
108
125
63
163
0
50
67
25
63
71
43
199
26
66
30
55
145
1
108
0
30
207
39
63
13
16
66
16
24
26
77
107
126
101
192
0
85
102
38
8
129
0
179
130
114
0
139
33
0
0
139
29
2
97
63
75
37
132
133
130
176
131
42
31
32
45
133
164
171
3
107
70
36
187...

result:

ok 100000 lines

Test #117:

score: 0
Accepted
time: 390ms
memory: 201088kb

input:

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

output:

6055
6055
0
3761
12038
13894
8064
0
13833
2229
5656
5447
5089
29
9361
1
113
1
3053
2521
14597
0
0
2047
13980
2924
0
282
4598
925
3653
4882
7638
11430
14082
10923
9979
4194
12924
14579
7682
5437
808
5370
254
932
14072
13168
1398
2516
3
15603
0
3889
2712
179
9324
15296
1
15878
3820
0
7774
3928
5419
11...

result:

ok 1000 lines

Test #118:

score: 0
Accepted
time: 420ms
memory: 189920kb

input:

100000 200000 1000
1 316
2 349
3 404
4 128
5 163
6 582
7 356
8 586
9 561
10 958
11 904
12 973
13 802
14 264
15 280
16 360
17 127
18 196
19 499
20 675
21 314
22 239
23 473
24 495
25 164
26 940
27 828
28 242
29 902
30 318
31 862
32 161
33 828
34 456
35 683
36 470
37 304
38 202
39 905
40 185
41 350
42 ...

output:

99
0
76
62
103
111
0
0
9
170
0
19
0
56
11
115
55
0
185
102
74
14
15
18
46
67
94
0
0
40
141
115
2
30
16
104
0
50
71
119
141
18
93
93
0
181
81
160
1
7
13
163
43
64
2
29
176
132
69
176
24
0
13
0
50
4
48
9
17
2
49
24
96
0
71
11
114
14
46
60
43
66
0
3
93
11
86
112
51
57
188
0
0
71
144
41
90
26
43
0
0
0
1...

result:

ok 1000 lines

Test #119:

score: 0
Accepted
time: 363ms
memory: 10264kb

input:

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

output:

281
269
311
532
233
23
578
488
87
552
219
551
549
77
522
22
446
582
610
72
358
451
490
348
594
338
551
26
425
519
99
564
543
5
61
622
380
608
578
587
299
63
353
350
106
254
168
507
491
342
573
180
264
558
609
283
558
471
451
482
413
360
400
17
558
539
557
633
570
477
426
508
497
600
258
263
351
437
...

result:

ok 100000 lines

Test #120:

score: 0
Accepted
time: 362ms
memory: 9868kb

input:

1000 200000 100000
1 242
2 419
3 478
4 496
5 603
6 628
7 286
8 290
9 305
10 966
11 832
12 759
13 492
14 944
15 746
16 276
17 437
18 472
19 463
20 119
21 670
22 333
23 739
24 879
25 171
26 68
27 60
28 469
29 490
30 927
31 772
32 463
33 953
34 53
35 524
36 930
37 216
38 101
39 852
40 124
41 680
42 581...

output:

350
577
483
565
391
246
292
545
290
242
493
492
144
572
409
201
464
544
579
487
423
429
524
568
286
5
337
338
443
468
408
454
501
365
479
360
571
298
513
47
400
462
212
437
78
553
277
378
86
414
424
466
84
144
396
351
556
223
362
96
193
351
577
152
157
163
425
360
523
101
113
181
86
380
354
216
446
...

result:

ok 100000 lines

Test #121:

score: 0
Accepted
time: 349ms
memory: 10488kb

input:

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

output:

437
418
104
213
281
491
478
411
14
275
397
268
226
272
467
358
460
549
54
30
40
505
241
498
460
311
435
7
218
481
216
429
396
542
532
303
469
512
253
-1
523
-1
-1
255
340
413
-1
135
401
246
496
311
515
117
251
445
-1
529
147
301
25
229
75
470
397
245
386
300
254
536
255
397
-1
289
212
531
462
459
53...

result:

ok 1000 lines

Test #122:

score: 0
Accepted
time: 356ms
memory: 9732kb

input:

1000 200000 1000
1 185
2 777
3 561
4 296
5 338
6 946
7 929
8 858
9 401
10 958
11 329
12 244
13 497
14 201
15 622
16 581
17 587
18 909
19 114
20 490
21 658
22 438
23 732
24 295
25 443
26 28
27 36
28 834
29 746
30 896
31 1000
32 742
33 524
34 194
35 207
36 350
37 844
38 319
39 1000
40 320
41 285
42 61...

output:

266
362
-1
218
233
476
331
364
200
408
162
390
365
289
236
298
218
320
427
368
422
510
249
-1
370
20
304
334
139
379
374
58
10
-1
258
414
380
390
-1
164
471
472
486
130
451
-1
-1
78
428
344
115
73
424
1
389
196
323
91
364
427
300
151
311
516
229
61
411
116
-1
79
447
-1
215
346
33
125
202
56
508
218
...

result:

ok 1000 lines

Test #123:

score: 0
Accepted
time: 469ms
memory: 244224kb

input:

100000 200000 100
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:

4839
47529
97933
18701
73314
97566
65915
361
19866
84685
75647
53940
42671
26347
13578
67865
85712
91573
92
22246
64644
31027
65443
90344
30795
31887
35187
44310
20035
85195
92322
85821
73169
22749
51755
85884
74491
57810
16375
3966
50398
84406
8269
15267
6224
67003
81942
1552
2151
33778
65696
3034
...

result:

ok 100 lines

Test #124:

score: 0
Accepted
time: 464ms
memory: 202356kb

input:

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

output:

3043
2160
0
56
3186
12981
12473
1164
7717
13409
897
1902
0
28
0
159
0
798
796
4499
16462
1441
1335
222
11949
1714
2773
1
1277
3604
8595
9161
12741
11163
7352
6985
11966
852
12435
3207
12696
10927
1599
243
8637
2173
1
91
2
2288
1
1
14262
681
0
4318
9276
639
2138
0
6622
447
9879
2788
6518
7570
408
-1
...

result:

ok 100 lines

Test #125:

score: 0
Accepted
time: 430ms
memory: 189320kb

input:

100000 200000 100
1 37
2 629
3 701
4 48
5 458
6 854
7 77
8 778
9 625
10 942
11 185
12 583
13 308
14 994
15 443
16 150
17 198
18 526
19 571
20 153
21 554
22 601
23 632
24 895
25 56
26 484
27 684
28 586
29 708
30 582
31 841
32 587
33 77
34 702
35 58
36 544
37 789
38 680
39 517
40 659
41 100
42 54
43 3...

output:

178
2
44
106
38
62
15
24
23
105
4
48
38
68
207
0
17
39
60
78
61
31
0
1
53
1
0
54
125
64
34
0
132
-1
8
0
1
78
0
4
129
0
0
0
156
0
0
20
0
97
37
136
9
107
27
27
43
10
0
70
2
0
156
70
85
0
21
74
193
11
31
8
0
89
20
44
85
25
38
0
50
109
46
34
88
26
10
60
134
4
0
42
4
103
196
0
45
0
68
8

result:

ok 100 lines

Test #126:

score: 0
Accepted
time: 507ms
memory: 244192kb

input:

100000 200000 300
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:

18407
22404
51683
51061
40464
56279
68878
14719
50485
35618
63821
21611
52847
59678
28492
84834
49242
10283
81021
70820
81764
75126
10340
50403
79686
39227
77664
71362
94220
44309
72030
24899
61676
32543
21412
91279
79425
74700
85566
41210
22857
37351
83727
81045
65394
91865
82865
98166
56087
36122
...

result:

ok 300 lines

Extra Test:

score: 0
Extra Test Passed