QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88061#4287. Box and Arrow Diagramxiaowuc1AC ✓134ms19052kbC++173.3kb2023-03-15 00:42:312023-03-15 00:42:32

详细

Test #1:

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

input:

3 4
1 2
2 3
1 2
3 3
7
2 2
2 3
1 4
2 3
1 1
1 3
2 3

output:

2
2
1
0

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 55ms
memory: 7644kb

input:

100 200000
54 60
71 12
62 88
84 30
30 11
3 9
10 26
95 81
78 66
31 31
94 79
50 14
72 80
52 8
80 55
59 74
5 96
2 49
78 53
95 6
98 60
69 23
1 98
9 84
54 35
28 89
24 80
51 25
41 23
8 24
66 60
63 31
43 44
37 12
55 77
56 69
88 72
2 16
9 22
10 53
16 42
48 48
17 100
90 28
82 55
43 25
94 11
76 88
90 34
57 54...

output:

2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
...

result:

ok 100000 lines

Test #3:

score: 0
Accepted
time: 53ms
memory: 7744kb

input:

100 200000
45 61
97 22
75 26
89 19
54 48
51 42
29 96
72 62
81 2
60 77
88 79
22 42
37 75
73 72
23 7
91 54
2 85
59 36
13 66
96 28
16 36
68 72
80 19
35 34
37 8
28 56
73 21
53 89
30 91
44 14
50 99
37 25
4 42
59 67
8 95
50 48
33 89
54 7
43 90
44 80
84 89
74 42
66 64
40 28
39 30
79 95
91 17
72 6
75 33
32 ...

output:

2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
...

result:

ok 100000 lines

Test #4:

score: 0
Accepted
time: 53ms
memory: 8044kb

input:

100 200000
28 93
43 83
79 23
46 89
41 34
97 100
5 33
21 95
59 45
96 99
14 40
19 17
12 47
23 71
43 73
57 91
40 83
22 69
53 49
95 37
40 100
52 87
35 4
69 78
97 33
63 94
48 31
70 77
96 89
41 49
69 38
8 60
38 41
16 48
81 51
84 77
7 13
29 21
53 31
69 19
31 54
73 41
73 80
34 7
98 66
32 99
82 87
82 67
77 4...

output:

2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
...

result:

ok 100000 lines

Test #5:

score: 0
Accepted
time: 63ms
memory: 7772kb

input:

100 200000
28 14
58 65
42 100
41 51
30 63
60 81
49 28
70 81
87 3
76 93
85 32
88 62
55 49
81 45
29 32
35 38
52 60
60 61
83 86
46 91
39 84
65 67
77 86
79 48
18 44
70 92
24 5
67 22
60 87
99 80
86 8
94 55
100 46
35 68
78 28
51 56
55 76
25 6
55 56
7 13
100 93
36 34
98 78
88 19
88 95
55 4
18 8
49 74
13 13...

output:

2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
...

result:

ok 100000 lines

Test #6:

score: 0
Accepted
time: 59ms
memory: 7640kb

input:

100 200000
59 25
1 56
51 30
55 92
16 54
72 62
94 78
79 25
61 39
100 100
1 87
28 29
100 50
91 81
13 29
29 16
46 22
46 13
27 70
20 83
13 4
42 56
97 80
45 68
94 65
90 16
36 85
36 16
60 92
51 92
87 95
2 47
93 63
12 54
8 35
63 49
37 29
95 33
11 37
15 8
80 48
62 77
79 65
25 54
100 47
61 21
16 9
13 41
79 3...

output:

2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
...

result:

ok 100000 lines

Test #7:

score: 0
Accepted
time: 43ms
memory: 8072kb

input:

100 200000
48 57
60 78
41 94
14 28
22 55
60 94
11 57
74 74
76 37
58 6
67 89
84 94
96 54
92 84
62 81
9 92
76 80
21 99
99 100
93 85
7 55
26 49
68 18
21 14
49 30
53 37
4 32
91 70
11 24
17 53
13 81
72 25
1 57
32 16
20 31
36 17
79 14
84 71
28 83
53 91
34 64
35 91
68 75
77 24
82 68
88 98
44 42
90 10
80 58...

output:

2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
2000
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
1999
...

result:

ok 100000 lines

Test #8:

score: 0
Accepted
time: 70ms
memory: 11704kb

input:

100000 200000
85961 1
84086 1
1 31033
46665 1
1 8253
70149 1
1 20135
53088 1
42080 1
95335 1
1 11288
1 57726
1 40556
35753 1
97690 1
1 56303
1 39763
1 97046
1 52123
78338 1
21564 1
36515 1
8982 1
1 75039
1 95193
1 41839
1 65593
1 24733
6519 1
1 31147
8419 1
82645 1
89940 1
1 51639
1 1837
24858 1
1 3...

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
99974
99973
99972
99971
99970
99969
99968
99967
99966
99965
99964
99963
99962
99961
99960
99959
99958
99957
99956
99955
99954
99953
99952
99951
99950
...

result:

ok 100000 lines

Test #9:

score: 0
Accepted
time: 64ms
memory: 11700kb

input:

100000 200000
93386 1
99370 1
2876 1
1 12779
1 63035
55643 1
1 73631
1 63337
98873 1
1 63360
14868 1
1 65434
33440 1
1 26220
1 47823
1 21071
1 40315
1 35739
68997 1
20107 1
28778 1
1 5360
1 4519
1 37467
23694 1
81761 1
1 49292
5395 1
1 39229
50257 1
51968 1
47009 1
33612 1
27162 1
33484 1
1 28809
1 ...

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
99974
99973
99972
99971
99970
99969
99968
99967
99966
99965
99964
99963
99962
99961
99960
99959
99958
99957
99956
99955
99954
99953
99952
99951
99950
...

result:

ok 100000 lines

Test #10:

score: 0
Accepted
time: 78ms
memory: 11808kb

input:

100000 200000
1 27001
62271 1
28946 1
1 62166
1 4283
85492 1
1 85260
1 48079
1 45455
1 45078
94610 1
1 81181
1 88662
89825 1
1 84650
90324 1
66735 1
1 85495
1 88394
86076 1
30612 1
1 90320
53317 1
1 62061
1 68973
98988 1
40447 1
11522 1
1 15600
40927 1
1 87314
1 60219
92337 1
1 12066
6802 1
1 29926
...

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
99974
99973
99972
99971
99970
99969
99968
99967
99966
99965
99964
99963
99962
99961
99960
99959
99958
99957
99956
99955
99954
99953
99952
99951
99950
...

result:

ok 100000 lines

Test #11:

score: 0
Accepted
time: 78ms
memory: 11708kb

input:

100000 200000
1 48052
97700 1
75585 1
32971 1
381 1
1 27074
1 63801
1 83205
75346 1
38222 1
69961 1
14367 1
74287 1
88704 1
96230 1
1 77050
1 92709
12661 1
34780 1
1 71459
1 97829
1 9451
48596 1
1 91726
1 98128
37281 1
52882 1
1 24057
18624 1
1 59168
1 15666
1 1083
1 39945
60498 1
80416 1
66733 1
57...

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
99974
99973
99972
99971
99970
99969
99968
99967
99966
99965
99964
99963
99962
99961
99960
99959
99958
99957
99956
99955
99954
99953
99952
99951
99950
...

result:

ok 100000 lines

Test #12:

score: 0
Accepted
time: 76ms
memory: 11700kb

input:

100000 200000
44377 1
1 62676
30738 1
1 20207
1 50905
78953 1
1 79570
75905 1
506 1
1 10087
69271 1
1 82132
46127 1
1 29151
1 18221
39838 1
1 3610
1 55777
1 78248
93638 1
24303 1
42840 1
80402 1
2955 1
1 45132
1 28343
86446 1
80957 1
1 56722
1 94285
2629 1
1 40537
1 12
1 18084
1 33175
1 74504
23578 ...

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
99974
99973
99972
99971
99970
99969
99968
99967
99966
99965
99964
99963
99962
99961
99960
99959
99958
99957
99956
99955
99954
99953
99952
99951
99950
...

result:

ok 100000 lines

Test #13:

score: 0
Accepted
time: 69ms
memory: 11708kb

input:

100000 200000
30605 1
23506 1
1 72285
1 27813
1 18761
15019 1
1 98391
1 10638
1 46994
1 33597
88467 1
6939 1
1 68062
38462 1
15132 1
1 28950
75058 1
49739 1
84050 1
1 96101
1 53063
88942 1
38721 1
14904 1
43279 1
1 14371
34720 1
1 85750
67884 1
1 52476
95409 1
1 23127
1 13759
46535 1
6973 1
3719 1
1...

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
99974
99973
99972
99971
99970
99969
99968
99967
99966
99965
99964
99963
99962
99961
99960
99959
99958
99957
99956
99955
99954
99953
99952
99951
99950
...

result:

ok 100000 lines

Test #14:

score: 0
Accepted
time: 115ms
memory: 19052kb

input:

200000 200000
139128 92143
149889 92969
64727 161800
147355 78409
126067 145038
180009 109901
175773 99590
90686 171026
86357 147124
199479 137294
83949 51720
86003 151855
92541 130973
78393 165794
175931 46425
136708 158725
69528 23689
19509 70205
57764 168034
66292 157290
155174 171786
33728 16480...

output:

1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 99587 lines

Test #15:

score: 0
Accepted
time: 129ms
memory: 18944kb

input:

200000 200000
111617 154172
438 22032
79202 110202
157025 135426
97549 26076
185567 54850
37009 83137
124898 85078
139638 111671
91627 2534
134707 167583
124479 70205
107408 52452
87777 99156
187699 192367
6175 126530
123901 105569
64486 111157
49781 49685
8090 89495
9476 56803
110962 64422
173908 1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 99913 lines

Test #16:

score: 0
Accepted
time: 115ms
memory: 18940kb

input:

200000 200000
157814 153406
150707 24959
134052 106227
179937 90924
113862 163102
21170 136235
114631 111531
16163 33389
108319 126009
64958 4211
3117 123723
131792 181485
141476 179066
197550 49328
146900 94661
13813 138028
119393 56840
149982 3433
49580 32413
9852 9561
32312 128268
140568 171953
1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 99914 lines

Test #17:

score: 0
Accepted
time: 134ms
memory: 18972kb

input:

200000 200000
159449 92750
32237 92690
71783 188558
69789 182063
88465 160080
42741 41604
71485 69592
17510 132324
15398 40763
72208 48847
147009 4002
110495 6988
85971 187425
65402 142769
111734 86350
155162 100362
48888 158077
126939 151503
62672 126909
165050 40537
131049 4986
5953 123319
126163 ...

output:

1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 99706 lines

Test #18:

score: 0
Accepted
time: 112ms
memory: 18932kb

input:

200000 200000
179701 199419
181734 14541
186734 139717
112958 149866
113191 47549
49186 134130
83579 177619
145934 151563
136355 117731
160345 138804
123982 51839
48674 119991
112970 166416
29064 99661
122131 10247
134287 33856
75742 145916
63704 93743
12060 132728
73770 87284
38405 158050
87603 341...

output:

1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 99937 lines

Test #19:

score: 0
Accepted
time: 92ms
memory: 19024kb

input:

200000 200000
125424 34571
67242 72860
70592 80650
74304 174233
2176 152259
68838 83724
175137 147267
132565 184519
187880 6468
30494 83695
14595 194177
159907 191624
7689 188947
19174 43277
48986 116197
43160 108536
18649 129683
162064 49223
120193 171025
186353 103773
190750 61084
112980 88591
151...

output:

1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 99995 lines

Test #20:

score: 0
Accepted
time: 91ms
memory: 13720kb

input:

100000 200000
60937 92514
23296 14685
57982 69050
1 61795
1 93397
1 25692
1 96033
40167 44483
25605 17436
39806 74787
65081 38967
1 10594
56915 9003
49766 55770
1 54528
1 70359
61851 2197
48596 79891
57211 30807
1 81201
1 90478
98932 67323
17059 73259
86383 40712
1 98842
1 25550
45048 79018
1 16580
...

output:

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

result:

ok 100000 lines

Test #21:

score: 0
Accepted
time: 78ms
memory: 13556kb

input:

100000 200000
83509 79219
1 82264
1 37773
1 40163
54860 53707
96088 67822
24335 27035
1 73557
1 42473
91213 86725
10062 21977
84653 84001
43717 83350
12193 96720
1 15150
75257 72697
56429 66009
83913 32514
12434 85936
8972 48816
66123 73830
1 18174
65390 25671
84558 71382
1 10162
1 44936
1 76455
1 2...

output:

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

result:

ok 100000 lines

Test #22:

score: 0
Accepted
time: 83ms
memory: 13556kb

input:

100000 200000
1 88695
1 35997
1 56268
89500 75838
1 21660
39079 64191
1 14293
46816 36626
69007 54919
94057 66325
1 80167
90063 14630
77856 45819
1 47012
1 82320
1 70439
29872 38301
8854 2346
1 91294
57243 98886
1 13706
1 55105
1 50560
37447 87399
86339 52985
75744 10233
8256 50480
38309 26171
1 360...

output:

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

result:

ok 100000 lines

Test #23:

score: 0
Accepted
time: 61ms
memory: 13624kb

input:

100000 200000
1 59972
4538 23638
71205 98114
1 46625
22242 24145
1 53032
1 81319
1 25194
1 18838
1 65845
1 199
4722 23485
1 71064
15879 68052
1 92898
76446 64398
1 2151
27060 84902
7925 65934
95863 96067
1 48517
1 32426
1 72044
1 12187
1 73782
1 54125
67791 45872
46737 98230
1 14694
54402 671
67584 ...

output:

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

result:

ok 100000 lines

Test #24:

score: 0
Accepted
time: 68ms
memory: 13656kb

input:

100000 200000
1 13276
1 79483
1 13344
48689 78452
1 91448
1 23019
87918 93561
2733 12155
99501 50013
72523 75693
1 78150
1 73533
1 7959
634 34529
1 17098
18317 64641
26562 43071
23196 73756
1 63184
1 70305
1 46415
1 78285
1 51084
29686 67576
72856 81854
1 39214
62628 65802
1 27116
64983 81980
50383 ...

output:

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

result:

ok 100000 lines

Test #25:

score: 0
Accepted
time: 49ms
memory: 7740kb

input:

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

output:

20276
20276
19962
19965
20127
19839
19964
19963
19837
19963
20013
20070
19837
19839
20276
20126
20125
20125
19962
20124
20124
19907
20124
20276
19833
20276
19838
19907
19957
19832
19957
20009
19961
20275
19907
20008
19957
20122
20274
19957
19957
19998
19998
19957
20007
19998
19961
19998
20068
20068
...

result:

ok 100000 lines

Test #26:

score: 0
Accepted
time: 45ms
memory: 7636kb

input:

10 200000
1 6
1 4
1 9
1 8
1 9
1 6
1 10
1 8
1 4
1 7
1 9
1 4
1 1
1 7
1 4
1 9
1 6
1 4
1 8
1 5
1 1
1 7
1 6
1 2
1 10
1 9
1 6
1 8
1 4
1 9
1 1
1 5
1 10
1 10
1 10
1 4
1 10
1 10
1 1
1 7
1 10
1 2
1 5
1 9
1 6
1 8
1 5
1 9
1 7
1 7
1 6
1 2
1 10
1 5
1 2
1 5
1 2
1 5
1 2
1 2
1 7
1 6
1 8
1 9
1 9
1 7
1 10
1 1
1 10
1 1...

output:

19890
20096
19924
19866
20095
19890
20143
19924
20095
19890
20095
20095
20095
19904
19904
19923
19892
19938
20238
19904
20099
19864
20237
19903
20237
19902
19886
20095
19891
20099
20095
20095
19862
20237
20092
19886
19886
19902
19886
19886
20141
19861
20235
19886
20096
19861
20096
19935
19888
20096
...

result:

ok 100000 lines

Test #27:

score: 0
Accepted
time: 48ms
memory: 7776kb

input:

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

output:

20015
20124
19691
20077
20134
19867
19866
19690
20076
20124
20134
19865
20134
19864
19864
19900
19900
20075
20014
20242
19900
20014
19688
20133
20133
20133
20133
20121
20079
19862
19687
19862
20133
20072
19686
20241
19862
20079
20079
20071
19898
20241
19861
20070
19897
20121
20241
20077
20241
20077
...

result:

ok 100000 lines

Test #28:

score: 0
Accepted
time: 42ms
memory: 7736kb

input:

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

output:

19696
19696
20179
19696
19694
19695
19695
20256
19695
19695
20179
19694
19694
19993
20023
20031
20179
19694
19996
19694
20070
20255
20255
20255
19694
20028
20255
19693
20255
20178
19995
20255
20255
19693
20028
19691
20178
20026
20022
19994
19987
20026
20022
20067
19994
20067
20067
19692
19987
20067
...

result:

ok 100000 lines

Test #29:

score: 0
Accepted
time: 57ms
memory: 7780kb

input:

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

output:

19850
20075
19844
19941
20126
19838
20126
20074
20156
19941
20074
20124
20063
20156
20073
20063
20063
20074
19941
20029
19836
20029
19839
20153
19848
19834
19940
20063
20073
20063
19847
19834
20029
20073
19838
19938
19938
19847
20072
19938
20071
20028
20151
19847
19838
19838
19832
20028
20028
19832
...

result:

ok 100000 lines

Test #30:

score: 0
Accepted
time: 71ms
memory: 8900kb

input:

10000 200000
5350 1
4850 1
9426 1
8038 1
1823 1
5209 1
717 1
8912 1
9279 1
3297 1
6867 1
3193 1
5038 1
9382 1
672 1
1890 1
766 1
629 1
1614 1
7104 1
9691 1
2955 1
1878 1
3965 1
2107 1
4017 1
6820 1
7246 1
2235 1
6815 1
9779 1
6521 1
8418 1
723 1
881 1
1982 1
4446 1
6499 6717
2277 1
4162 1
1339 1
454...

output:

190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001
190001...

result:

ok 200000 lines