QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#649944#7181. Graph Cutsucup-team4796#AC ✓177ms270572kbC++174.9kb2024-10-18 11:41:282024-10-18 11:41:28

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 5
1 2
1 3
1 4
2 3
2 4
10
+ 1
+ 2
?
?
?
?
?
- 2
?
?

output:

5
4
3
2
0
1
0

result:

ok q=10

Test #2:

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

input:

0 0
0

output:


result:

ok q=0

Test #3:

score: 0
Accepted
time: 4ms
memory: 28340kb

input:

0 0
1
?

output:

0

result:

ok q=1

Test #4:

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

input:

1000 2000
1 50
1 88
331 1
1 352
1 497
2 32
2 282
550 2
989 2
334 3
3 665
4 38
4 69
4 343
4 451
589 4
917 4
89 5
5 162
675 5
681 6
7 22
127 7
7 592
7 672
787 7
8 310
107 9
9 137
184 9
9 244
378 9
446 9
9 658
883 9
65 10
75 10
414 10
10 468
686 10
245 11
269 11
11 386
403 11
493 11
394 12
493 12
565 1...

output:

208
1990
1958
779
1475
1474
854
879
1928
1917
847
1187
1848
1043
657
1768
1741
1304
837
836
852
851
89
1183
949
1421
1696
340
1190
278
1182
896
895
1968
743
846
754
1880
1562
1422
972
1561
1560
1877
1857
1838
1557
1556
853
1789
1788
1648
426
1851
1956
1783
1695
1279
667
1797
1796
1076
1075
1993
1860...

result:

ok q=100000

Test #5:

score: 0
Accepted
time: 136ms
memory: 160280kb

input:

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

output:

77103

result:

ok q=100000

Test #6:

score: 0
Accepted
time: 135ms
memory: 162240kb

input:

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

output:

29181
19080
62280
41028
99120
62006
98646
95586
87435
99636
97728
63366
53625
84105
46379
32519
76027
64169
93794
22652
66784
66010
47030
28804
28803
93464
58064
1334
49277
17871
17868
98249
42389
20677
99545
98691
98688
63635
47999
16244
16243
32885
62824
22259
3100
72419
99404
41710
76245
99489
61...

result:

ok q=100000

Test #7:

score: 0
Accepted
time: 101ms
memory: 99240kb

input:

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

output:

64436
66011
891
52095
52094
90090
90089
65751
23045
99678
91553
37553
66528
66527
48000
93353
54531
41028
74928
74927
74926
74924
74923
74922
94325
94324
94323
98456
98455
3978
83388
40685
28428
58353
29553
29549
11268
11264
11259
58640
58639
92300
49278
62280
62279
95025
26145
26144
9581
9580
3540
...

result:

ok q=100000

Test #8:

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

input:

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

output:

0
48960
37553
99671
99670
97196
66785
77526
9156
9155
9154
90365
90364
90363
88205
88204
88203
88202
88201
88199
83210
83209
83208
83207
96755
87591
87590
87589
87588
13361
14190
14189
14188
14187
46053
70035
70034
90770
90769
91806
91805
91804
91803
98456
89385
97403
97402
97401
12940
94325
94324
5...

result:

ok q=100000

Test #9:

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

input:

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

output:

0
0
0
0
0
0
0
0
33251
33250
33249
33248
33247
96360
97403
97402
97401
97400
97399
65490
65489
65488
65487
65486
87278
87277
87276
98303
98302
98301
86151
86150
86149
86148
99246
38256
38255
38254
38253
38252
38251
38250
96906
99645
99644
99643
99642
99641
99640
60621
90228
72186
72185
94010
94009
43...

result:

ok q=100000

Test #10:

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

input:

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

output:

0
0
0
0
62553
62552
62551
62550
62549
62548
62547
62546
99660
99659
99658
99657
99656
99655
20678
20677
66785
66784
66783
66782
66781
66780
24215
24214
24213
24212
24211
24210
24209
24207
24206
24205
24204
24203
24202
84975
84974
84973
84972
84971
84970
84969
84967
84966
84965
84964
84963
84962
8496...

result:

ok q=100000

Test #11:

score: 0
Accepted
time: 15ms
memory: 33092kb

input:

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

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 q=100000

Test #12:

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

input:

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

output:

63093

result:

ok q=100000

Test #13:

score: 0
Accepted
time: 150ms
memory: 162696kb

input:

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

output:

98549
98547
80371
80369
80368
91421
98735
72420
88802
88801
39995
19481
81914
81913
64965
73115
79980
65750
99245
28427
88949
446
48959
78152
96600
60059
80959
35060
36135
99427
56610
32886
95215
95214
2660
33250
90500
96520
99666
1778
31045
50540
84105
56902
86961
68555
98406
57195
2220
99671
53321...

result:

ok q=100000

Test #14:

score: 0
Accepted
time: 111ms
memory: 98844kb

input:

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

output:

93685
76675
24989
88204
75591
75587
41028
62824
62823
56021
56017
89528
89524
89523
89521
70519
70518
61731
97196
97192
97191
93353
10005
10004
98978
67295
67294
50539
73802
74256
96980
38256
72185
65490
74704
74703
63634
63633
87591
35061
35057
11271
86961
93352
93351
88654
88653
97851
81726
92541
...

result:

ok q=100000

Test #15:

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

input:

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

output:

69053
69052
86148
2658
79377
79376
79375
88800
88799
88798
88796
85650
98193
33615
67803
63093
63092
63091
39303
39302
94527
94526
94525
94523
94519
94517
94516
94514
67800
99666
99665
99664
91680
91679
67550
67549
67548
38256
38255
38254
38248
38247
59492
59491
74030
74029
96755
85313
85312
85146
8...

result:

ok q=100000

Test #16:

score: 0
Accepted
time: 44ms
memory: 66156kb

input:

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

output:

10428
52710
50852
50849
50848
50845
50843
78565
58065
58063
58062
58059
58058
18275
18273
36490
32153
32151
10849
97600
97597
97596
28428
28426
13775
13772
13768
13766
13764
13762
13761
13760
95310
95308
60899
60896
60892
98085
98083
6153
12944
92777
92774
15835
15832
76675
76672
76668
76666
76664
7...

result:

ok q=100000

Test #17:

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

input:

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

output:

96600
77315
77313
77310
97728
97726
97723
17466
17464
78152
78150
78149
79178
79176
79173
79172
79171
79169
79167
79165
79163
35777
40340
40338
40337
40333
40331
40329
40327
40324
40323
40322
40321
40319
40318
40316
40315
40314
40312
80571
80569
80566
76676
76674
76671
76670
76669
76667
76665
76663
...

result:

ok q=100000

Test #18:

score: 0
Accepted
time: 12ms
memory: 33704kb

input:

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

output:

81915
81913
81912
81910
81909
81904
81903
81901
81899
81896
81893
81890
81889
81888
81887
81884
81883
81882
81881
81878
81875
81872
81866
81865
81862
81858
81857
81856
81854
81853
81850
81848
81844
81843
81842
81840
81839
81837
81835
81834
81833
81830
81828
81825
81824
81823
81822
81821
81819
81818
...

result:

ok q=100000

Test #19:

score: 0
Accepted
time: 152ms
memory: 161944kb

input:

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

output:

99330

result:

ok q=100000

Test #20:

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

input:

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

output:

48960
48959
26503
98735
96278
18678
18677
64436
28805
98600
74030
74029
66528
99615
83203
87900
87899
40685
95403
99666
99405
17466
23436
19881
26145
56316
36491
36490
99680
85653
55725
33251
87120
75589
36489
98028
98027
23826
98406
92541
97052
97051
97046
97042
81152
81153
81150
81149
81148
99470
...

result:

ok q=100000

Test #21:

score: 0
Accepted
time: 95ms
memory: 97700kb

input:

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

output:

42728
89951
69546
64965
78566
97196
99680
14603
14602
14599
71478
77736
99246
31785
40685
36491
92658
89811
92300
92299
18678
18677
75810
99545
67803
70759
95495
71001
98600
98599
9579
9578
79781
81726
91806
91805
96195
98818
98085
98978
8303
94116
76676
4849
88801
63366
93574
84973
84972
85316
8531...

result:

ok q=100000

Test #22:

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

input:

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

output:

0
0
97196
97195
97194
15426
15425
15424
78771
60060
98691
98690
99303
99302
99301
83210
94631
27671
89528
90228
90227
90226
90225
90224
90223
90221
90220
90219
53016
53015
53014
79781
91290
96521
96520
97470
99626
99625
99624
99623
99275
99051
99050
36135
36134
36133
29930
59495
90636
90635
84975
96...

result:

ok q=100000

Test #23:

score: 0
Accepted
time: 65ms
memory: 65016kb

input:

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

output:

81345
66011
66010
66009
66008
66007
88506
88505
88504
88503
50226
47355
47354
47353
81153
81152
81151
81150
19481
19480
16653
16652
16651
16650
6585
6584
6583
6582
6581
6580
89811
89810
89809
89808
89807
89806
89805
92660
88356
88355
88354
72885
72884
72883
72882
72881
38606
69300
69299
99356
99355
...

result:

ok q=100000

Test #24:

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

input:

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

output:

0
0
0
0
94325
94324
94323
94322
94321
94320
59495
59494
59493
59492
70035
70034
70033
70032
70031
70030
70029
70028
70027
70026
70025
70024
70023
61731
61730
99428
91553
91552
56610
56609
56608
51165
97911
97910
97909
97908
97907
40685
92541
92540
90228
56316
56315
56314
98456
98455
98454
98453
9845...

result:

ok q=100000

Test #25:

score: 0
Accepted
time: 14ms
memory: 32308kb

input:

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

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 q=100000

Test #26:

score: 0
Accepted
time: 148ms
memory: 164284kb

input:

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

output:

53093

result:

ok q=100000

Test #27:

score: 0
Accepted
time: 142ms
memory: 164156kb

input:

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

output:

79124
32194
32193
2221
61277
68672
99895
56986
79116
89285
10442
10441
96686
99934
96178
5293
39356
70397
47750
99747
90562
41428
11706
56110
98292
22285
99565
87614
100000
9594
9590
79933
79932
79931
89862
89858
98778
7024
78506
87616
87612
76167
31825
88541
88540
21495
90145
32928
96767
84626
9600...

result:

ok q=100000

Test #28:

score: 0
Accepted
time: 102ms
memory: 100192kb

input:

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

output:

4422
49662
49661
16678
16677
16676
72304
72303
72302
90141
94123
94122
87766
72539
98050
54908
80719
80718
74605
71356
94858
55208
62375
6163
51857
83535
55804
97588
99505
95822
95821
92628
9596
9595
90133
91100
98407
43459
43458
43457
43456
43455
40737
53701
18707
99999
99998
78910
78909
78907
8664...

result:

ok q=100000

Test #29:

score: 0
Accepted
time: 67ms
memory: 65260kb

input:

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

output:

98110
98109
99504
99503
99502
1336
1335
26938
69896
69895
69894
99997
99864
99922
99921
12116
58429
58428
95726
95725
94545
99984
47742
93790
93789
93784
96263
96262
96257
68404
68403
68398
68397
88380
88379
5287
5284
5283
18290
18289
98515
98514
98509
98508
98507
98506
98505
28078
28077
28072
74375...

result:

ok q=100000

Test #30:

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

input:

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

output:

0
79924
79923
79922
79921
79920
81299
81298
81297
92989
92988
51230
51229
72772
72771
72770
72769
72768
99260
46110
46109
95157
31452
31451
59293
59292
59291
59290
59289
71355
71354
71353
67399
67398
67397
67396
67395
67394
98873
98872
46438
33291
33290
96603
96602
49974
99829
99747
99746
99745
9974...

result:

ok q=100000

Test #31:

score: 0
Accepted
time: 39ms
memory: 50912kb

input:

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

output:

0
0
0
0
0
0
93449
93448
93447
93446
93445
93444
93443
93442
91493
91492
91491
91490
21492
21491
81108
77235
77234
77233
77232
77231
78081
78080
78079
78078
78077
78076
78075
78074
78073
78072
78071
78070
78069
78068
78067
78066
5727
99829
99828
99827
99826
99825
99824
99823
99822
99821
99820
99819
9...

result:

ok q=100000

Test #32:

score: 0
Accepted
time: 16ms
memory: 33020kb

input:

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

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 q=100000

Test #33:

score: 0
Accepted
time: 177ms
memory: 164088kb

input:

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

output:

4855

result:

ok q=100000

Test #34:

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

input:

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

output:

7445
76367
76365
76364
99791
99595
68156
95253
96090
95155
99910
80516
12121
34010
5282
93105
93104
68904
13370
47408
47407
67390
17077
74152
84783
99366
1778
99955
92257
85814
86480
92133
92007
92002
77019
26175
26172
11700
99536
891
888
95820
95910
99370
8733
92258
97001
97000
96998
99811
66623
83...

result:

ok q=100000

Test #35:

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

input:

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

output:

82997
82994
92501
55504
45455
31825
90692
99011
51232
97443
97440
97439
42782
99404
35104
35103
35101
35098
35097
35094
35093
6592
69154
68656
68655
29216
29215
29213
36177
42443
43455
82439
82436
32925
77864
93218
28460
94437
26177
26176
76150
75931
17889
17887
97721
44790
44788
78698
98288
97149
8...

result:

ok q=100000

Test #36:

score: 0
Accepted
time: 86ms
memory: 99384kb

input:

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

output:

15445
15443
89724
96685
96684
51244
51243
51241
51238
55511
89435
89433
73932
92266
92265
44139
99473
93572
93571
93569
90010
61551
61549
21103
15447
15446
15444
15441
81500
81498
20705
72544
72542
72541
72539
72538
86658
95450
95449
96924
96923
96921
96918
96914
96912
95448
98112
7457
7456
7454
711...

result:

ok q=100000

Test #37:

score: 0
Accepted
time: 58ms
memory: 65840kb

input:

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

output:

36186
36185
96429
98870
89858
89857
80909
80908
80907
80904
47424
93332
93331
93328
93327
93325
93322
93320
18695
18694
99892
99891
11700
19500
90965
10860
62099
62098
62097
47744
26177
26176
26173
58151
58150
58149
58146
58145
58142
99406
99405
99404
99401
98873
98872
98871
98868
98867
98864
98862
...

result:

ok q=100000

Test #38:

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

input:

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

output:

81300
81299
81298
81293
81292
81291
64792
64791
60701
60700
60699
73693
73692
80320
70627
70626
70625
70620
70619
70618
70616
70615
70614
70611
13367
13366
97148
97147
97146
97145
92257
92256
92255
82066
82065
82064
28081
28080
28079
28074
33284
33283
33282
33281
33277
35461
35460
35459
35454
35453
...

result:

ok q=100000

Test #39:

score: 0
Accepted
time: 16ms
memory: 31648kb

input:

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

output:

99863
99861
99860
99859
99858
99856
99854
99852
99851
99849
99831
99813
99774
99731
99708
99659
99549
99519
99488
99355
99319
99282
99244
99205
99124
99082
99039
98995
98857
98710
98500
98215
98155
97906
97841
97708
97640
97501
97430
97212
97137
96502
96333
95893
95710
95617
95428
95332
95235
94838
...

result:

ok q=100000

Test #40:

score: 0
Accepted
time: 147ms
memory: 163908kb

input:

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

output:

62637

result:

ok q=100000

Test #41:

score: 0
Accepted
time: 151ms
memory: 164236kb

input:

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

output:

34015
21494
25786
96515
45785
99747
97445
97444
97442
99259
78077
78076
78074
98726
27699
27698
97723
90829
90828
91097
95251
18695
30707
89568
89567
90826
84262
5288
5285
3980
64534
65065
60151
10859
3542
63461
99790
77656
62920
62917
79921
62374
24627
52474
99138
99810
99979
57279
72303
27697
8760...

result:

ok q=100000

Test #42:

score: 0
Accepted
time: 106ms
memory: 99772kb

input:

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

output:

0
14200
99990
91759
91758
80329
95999
95998
71597
71596
89290
97374
45455
45454
93457
93456
100000
99997
96175
46111
46109
95350
95348
53394
92630
11277
29211
63458
63456
77664
77662
99972
99944
72071
72069
72066
42101
42099
88239
89865
89863
77665
84450
84974
71358
72306
99999
99979
48704
9589
5727...

result:

ok q=100000

Test #43:

score: 0
Accepted
time: 77ms
memory: 65764kb

input:

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

output:

0
0
0
0
0
0
0
65322
65321
65320
97374
97373
91228
91227
91226
78496
82249
6593
6592
6591
52467
52466
52465
52464
85062
65249
65226
99880
98726
98725
98724
40729
40728
65585
97587
97586
97585
98718
35456
93562
99252
99244
99239
97548
97335
55497
55496
55495
68908
68907
68906
97219
97211
97157
98825
9...

result:

ok q=100000

Test #44:

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

input:

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

output:

43120
43119
43118
43117
82261
78503
78502
78501
78500
78499
78498
78497
78496
78495
78494
78493
44791
65589
58251
58232
4858
4857
4856
4855
4854
4853
4852
75280
75279
94856
36535
36534
66372
47415
100000
74608
67145
67144
67143
67142
95908
95907
95906
98347
96433
96432
9163
94547
94546
892
80126
801...

result:

ok q=100000

Test #45:

score: 0
Accepted
time: 37ms
memory: 50640kb

input:

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

output:

0
75271
75270
75269
75268
97299
97298
97297
97296
97295
97294
97293
97292
97291
97290
97289
53088
53087
68909
62912
62911
62910
99675
99674
99673
99672
99671
99670
99669
99668
99667
99666
99665
99829
99828
99827
99826
99825
99824
99823
86314
86313
86312
86311
86310
86309
86308
86307
86306
86305
8630...

result:

ok q=100000

Test #46:

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

input:

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

Test #47:

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

input:

100000 100000
5722 1
35633 1
76503 1
2 8454
2 93428
3 91414
4 55025
21132 5
6 22400
6 80941
7 22043
7 29361
7 73158
78568 7
8 24159
8 26175
27612 9
39375 9
5454 10
24262 10
40601 10
11 8620
59525 11
11 79781
11 92891
64034 12
33728 14
14 59378
14 79826
560 16
16 31445
35262 16
17911 17
28509 17
9364...

output:

9415

result:

ok q=100000

Test #48:

score: 0
Accepted
time: 36ms
memory: 34040kb

input:

100000 100000
32763 1
1 41318
52251 1
66464 2
83572 2
67186 5
7 64990
34545 8
8 96178
8628 9
10 8181
94794 15
16 33467
16 34451
85594 16
17 20413
31799 17
17 41753
18 61787
71853 18
19 5788
19 49136
97968 19
34661 20
20 61751
95244 20
20211 21
31082 21
22 96882
53538 23
53831 24
81268 24
25 52202
61...

output:

48490
48489
23102
30538
94777
53585
53584
12375
93652
42757
31024
26264
76827
21768
98186
73435
44592
5804
75074
75073
96496
51181
71805
18985
32508
88791
76920
31733
66520
66519
91248
5177
15971
81311
73831
26010
98826
43463
8664
97482
59494
75938
55011
79160
91763
541
540
82244
67980
96778
95965
5...

result:

ok q=100000

Test #49:

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

input:

100000 100000
98 1
1 39536
2 7197
2 36925
64304 2
3 90981
4 55694
4 58594
6 14112
6 61223
49657 7
49961 8
9 63064
84290 9
9616 10
10 26834
10 81424
11 28592
66665 11
11 67518
12 65671
12 77007
13 83518
88724 13
14 22525
28934 14
38904 15
18454 16
16 34371
33103 17
63576 17
46939 18
67514 18
18 72374...

output:

84279
63805
15691
31330
254
16068
96086
72114
41137
32562
4317
59932
31397
92752
8020
90151
89237
99011
92871
42932
54198
51863
10169
96533
87108
83147
83146
94693
69445
63739
62073
54550
54549
51916
43326
95801
94649
96987
81022
44545
41930
99923
93480
65469
65468
60315
52076
99854
92744
15719
1571...

result:

ok q=100000

Test #50:

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

input:

100000 100000
1 30554
51310 1
1 71883
94585 1
2 40250
59351 2
2 60517
72989 3
4 3248
14035 4
4 90751
5 786
6 10125
87221 6
22862 7
7 57323
67940 7
40455 8
8 66854
9 34854
9 87440
43694 10
10 57462
82982 10
94968 10
47934 11
11 71829
24007 12
44565 12
48286 12
70260 12
12 70368
98761 12
20547 14
7549...

output:

71478
71477
50261
40431
49551
49550
26532
58649
52035
76839
35164
14556
3271
3270
3269
50164
34109
99176
8106
56894
9191
10949
82770
76203
63000
16879
31355
41209
98697
76160
18538
78771
66650
3678
97329
22738
22737
33368
95234
71439
50660
33367
25349
21390
63519
63518
81621
72751
31092
87092
68347
...

result:

ok q=100000

Test #51:

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

input:

100000 100000
26140 1
46196 2
2 54845
78912 3
3 90871
4 12358
5 33609
5 43410
5 78393
47818 6
7 48862
13216 8
8 36636
8 40979
52931 8
8 80000
94821 8
52306 10
14072 12
36807 12
66342 12
344 13
13 4469
13 14570
13 52573
15 29037
15 38532
86576 15
16 9718
43023 16
16 86523
19 16448
20 15703
20 62471
8...

output:

0
0
0
0
33676
0
0
0
81127
70591
38372
38371
38370
25083
25082
19896
19895
43568
28482
96503
69480
12956
12955
12954
9074
9128
9127
9126
12953
6360
76367
61668
1281
81918
22544
62238
28457
13771
14145
81470
81469
81468
62237
48282
845
34967
88273
88272
67816
59096
40004
35692
11407
90105
90104
90103
...

result:

ok q=100000

Test #52:

score: 0
Accepted
time: 23ms
memory: 33088kb

input:

100000 100000
2005 1
1 15170
57799 2
4 38977
4 57240
42542 5
5 53318
5 75678
6 88650
65147 7
8 53626
8 70633
22352 10
11 49862
12 14548
12 50661
12 69416
13 22675
13 57792
3230 14
61629 16
16 94304
19 4752
11292 19
19 23963
47970 19
3280 20
20 13431
37640 20
20 43437
22 59910
69629 22
94875 22
23 52...

output:

0
0
63812
63811
0
0
0
0
0
0
0
0
0
0
0
0
0
64070
0
0
0
0
0
0
0
0
0
0
0
0
0
17931
17930
0
0
0
0
0
0
0
0
0
0
25349
25298
22976
0
63870
46890
79011
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
74503
57471
54550
49655
23473
0
0
0
0
79932
79931
55883
0
0
0
0
0
0
0
0
95579
95578
94320
0
0
93452
72970
0
0
0
0
0
0
...

result:

ok q=100000

Test #53:

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

input:

100000 100000
40394 1
75982 2
3 18844
73366 3
88698 3
4020 6
6 73638
7 22013
65853 7
8 75952
8 91846
8 92431
35947 9
25852 10
60988 10
84698 10
49696 11
60792 11
94447 12
29797 13
14 32289
14 45866
85823 14
15 5953
19579 15
9976 16
16 26641
17 70399
80811 17
18 57277
19 24826
19 72978
15405 20
64474...

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 q=100000

Test #54:

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

input:

100000 100000
1 46719
1 85926
2 31507
3 10325
25701 3
4 20660
4 24390
5 28826
5 32895
5 65707
5 85849
26769 6
35848 6
8 31592
9 6175
10 10273
10 49762
8543 11
12 1257
12 49533
67310 12
12 85402
4042 13
13 91901
14 36759
95374 14
40235 16
16 95131
17 47185
49412 17
86267 17
30733 18
19 36525
99630 20...

output:

45927

result:

ok q=100000

Test #55:

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

input:

100000 100000
1 14816
1 36843
1 67254
69974 1
3 22460
4 94861
51245 5
5 53683
54692 6
6 91387
6 91712
8 56288
8 88631
9 4475
23107 9
9 37340
18545 10
10 32507
10 37510
86500 10
57406 11
11 96238
486 12
12 44026
51175 13
14 92685
14 94886
14 99844
66818 15
58293 16
16 92531
17 32186
36963 18
18 53409...

output:

35268
67766
38280
38279
12361
29784
63672
40056
31178
31176
93174
90168
90167
57760
72285
33621
27140
61458
12758
11872
74423
94666
50463
98499
75520
42260
54961
50159
29707
16331
95692
66462
79150
48130
29141
42384
77744
88446
69442
16563
11115
83504
73079
62889
13426
13425
16304
87145
37048
40295
...

result:

ok q=100000

Test #56:

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

input:

100000 100000
1 92961
32241 2
2 81221
4608 3
16927 3
18769 3
3 43374
22317 4
55044 4
18810 5
6 72739
61007 7
9 25577
9 27864
34366 9
10 16913
30734 10
40980 10
60805 10
74697 10
82279 10
10021 11
23696 12
36468 12
51197 12
86124 12
12 89628
14 6535
14 21742
14 36158
57841 14
15 81216
15 84873
16 457...

output:

73693
3466
84146
84326
40253
27078
23949
99712
47442
47441
2834
99711
99350
74472
74988
93440
22851
7420
58909
20392
98409
97340
93699
78783
87174
85774
1854
3661
7832
91431
53486
24739
24738
18497
14319
77739
68718
30629
48953
23956
50189
60595
60594
86770
71804
42739
50286
29785
79787
50185
23657
...

result:

ok q=100000

Test #57:

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

input:

100000 100000
1 27333
1 84324
96084 1
9114 2
85952 2
3 5372
4 6733
9091 4
58622 4
4 86657
14441 5
55881 5
77265 5
5 80838
6 348
8 52617
8 61683
11583 9
9 73540
93581 9
94661 9
9 98721
46654 10
10 52226
12 55380
12 79729
13 40841
13 58505
80468 13
57058 14
14 59095
23508 15
68757 15
6286 17
17 39373
...

output:

76664
76662
15523
75098
95383
65411
36319
15196
5030
23234
65410
68262
90047
25342
52816
65137
6141
65135
32060
34206
25025
65919
9412
14160
69922
51848
57353
81774
44862
44861
21506
5928
34116
80725
57934
33682
4801
66918
4847
4845
11445
40499
18488
76898
74644
71781
55884
34639
25844
10107
40354
6...

result:

ok q=100000

Test #58:

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

input:

100000 100000
60818 1
1 61357
77477 1
3 45025
59533 3
46950 4
78991 4
97104 4
36194 5
6 64485
1740 7
5623 8
23553 8
16292 9
62566 9
9 98158
10 23566
10 47129
84382 10
10 89508
11 12522
54918 11
82691 14
89591 14
15 22620
22939 16
56415 16
16 83923
18 29619
18 83502
19 24669
79130 19
43646 20
21 6966...

output:

74007
9947
4485
10067
10066
98490
66813
29589
96152
55629
22458
38757
31695
56241
31081
57833
50128
86173
73846
9234
59912
59910
4135
35738
90297
23291
67470
24008
23290
14072
13394
77120
64655
28484
82335
59927
40733
68581
94650
5829
80814
80420
77595
98071
94649
18814
61265
17500
3003
76643
22996
...

result:

ok q=100000

Test #59:

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

input:

100000 100000
34616 1
58002 1
1 70045
10303 2
2 39631
40632 2
10056 3
41853 3
70173 3
4 92959
5 47483
16468 6
50684 6
67732 6
84535 7
47014 8
59046 9
10 65208
10 78362
11266 11
24545 11
12 21449
66415 12
92002 12
13 19643
13 23316
96267 14
91298 15
17801 16
49544 16
69757 16
4694 17
17 24548
221 18
...

output:

7975
46841
19948
19945
77332
70244
66255
94834
82655
60389
5693
14572
98772
14571
14570
56107
41952
76231
64343
95951
68709
68708
68707
98335
82156
82044
99013
76501
82261
82260
30352
18930
62495
44163
34378
43805
8545
51328
10860
19702
64903
2906
59260
51199
77654
75573
75572
42523
85724
47551
7181...

result:

ok q=100000

Test #60:

score: 0
Accepted
time: 23ms
memory: 33832kb

input:

100000 100000
1 14279
25034 1
1 25644
1 33907
55554 1
32635 2
48898 2
67742 2
30821 3
62159 3
62878 4
4 99567
5427 5
81073 5
40389 6
68943 6
86783 6
7 7357
8 43901
8 49165
66447 8
15193 10
10 27651
52896 10
11 21927
31071 11
65058 11
1885 12
12 86604
13 34951
13 57211
73415 13
76672 13
31146 14
4934...

output:

1201
84344
90122
48345
19249
11970
11969
47027
9038
6134
56437
56436
56435
70843
89135
99322
42387
89830
55305
99738
19474
6556
93972
93971
75649
75589
57927
54178
38470
58449
58447
3262
1852
58545
58544
97460
94629
53997
66398
13641
71349
71348
71347
97653
25771
88621
74304
12721
85406
85405
15115
...

result:

ok q=100000

Test #61:

score: 0
Accepted
time: 33ms
memory: 35564kb

input:

100000 100000
36686 1
2 28317
3 43331
58975 3
9005 5
5 38587
85424 5
87253 5
91242 6
7 12636
7 28747
43112 7
56525 7
95056 7
8 67866
8 96414
15486 9
9 17569
9 27913
9 45216
57385 9
12037 10
10 26847
68194 10
10 69558
91082 10
1181 11
29864 11
11 51315
74564 11
11 99360
50347 12
12 70424
80616 12
810...

output:


result:

ok q=100000

Test #62:

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

input:

100000 100000
19575 1
26203 1
72508 1
1 97963
14667 2
16976 2
3 6175
3 67390
3 85817
3 95274
61098 4
5 63076
48837 6
6 85456
8 11139
8053 9
9 14304
9 42080
78302 9
87001 9
95714 9
10 11640
10 38250
11 68261
33284 12
34067 13
37576 13
13 83578
15 23823
35578 16
57809 16
17 35284
43161 17
17 47477
516...

output:


result:

ok q=100000

Test #63:

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

input:

100000 100000
36059 1
46485 1
23653 2
73424 2
2 74494
51828 3
4 33328
53661 4
34793 5
6 51871
55444 6
6 65656
8 16246
8 34477
10425 9
62445 9
21534 10
10 30313
60761 10
96061 10
7597 11
11 15469
63367 12
40382 13
14 75126
15 56288
15 84929
53927 16
64468 16
17 53139
18 5845
76176 18
19 24677
19 5891...

output:


result:

ok q=100000

Test #64:

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

input:

100000 100000
20177 2
2 98955
3 46743
3 46866
62628 3
12631 4
75181 4
5 54593
27546 6
6 31901
6 83336
6 90688
7 32220
7 63366
8 61776
37721 9
9 48206
9 70008
96585 9
10 62990
98079 10
11 11607
21944 11
11 80964
13 9208
13 49235
13 69968
13 85800
38176 14
57272 14
15 3765
16 67576
17 40546
17 44435
1...

output:


result:

ok q=100000

Test #65:

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

input:

100000 100000
1 33218
2 26924
4 22063
4 72727
83189 4
5 26165
50928 5
6 12110
17480 7
39161 7
7 76692
20436 8
36025 8
9 52297
9 58874
67940 9
10 17168
10 40179
10665 11
11 26766
11 26798
28558 11
41443 11
91932 11
11 96520
12 38384
89050 13
14 44040
14 60933
63286 14
14 91796
38298 15
83369 15
20977...

output:


result:

ok q=100000

Test #66:

score: 0
Accepted
time: 35ms
memory: 35580kb

input:

100000 100000
97038 1
2 12394
73478 2
27345 3
3 52828
3 94198
17649 4
34700 4
4 48092
90308 4
4 92571
5 73178
5 96066
1197 6
79796 6
6 95080
7 6897
7 96564
8 57604
8 70048
29738 10
10 42975
10 99064
11 20156
11 25952
51206 11
11 97949
38714 12
92965 12
10950 13
15 6617
8272 15
17383 15
37580 15
5035...

output:


result:

ok q=100000

Test #67:

score: 0
Accepted
time: 33ms
memory: 33928kb

input:

100000 100000
1 43054
1 66061
45045 4
81759 5
15827 6
6 40801
78430 6
6 83704
3488 9
32237 9
10 8261
10 37635
98555 10
82566 11
30294 12
68894 12
13 32989
92708 14
94972 14
15 41948
16 28327
20490 17
52712 17
18 23230
18 77251
9533 19
66382 19
20 10583
23214 22
32369 22
24 32167
75443 24
26 9052
278...

output:


result:

ok q=100000

Test #68:

score: 0
Accepted
time: 47ms
memory: 270496kb

input:

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

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 q=100000

Test #69:

score: 0
Accepted
time: 44ms
memory: 268964kb

input:

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

Test #70:

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

input:

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

output:

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

result:

ok q=100000

Test #71:

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

input:

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

output:

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

result:

ok q=100000

Test #72:

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

input:

99970 100000
2 1
1 3
5 1
7 1
9 1
1 11
13 1
15 1
1 17
1 19
1 21
1 23
1 25
27 1
1 29
31 1
1 33
1 35
37 1
1 39
1 41
1 43
45 1
47 1
1 49
51 1
1 53
55 1
57 1
59 1
1 61
63 1
65 1
1 67
69 1
71 1
73 1
75 1
77 1
79 1
81 1
1 83
85 1
1 87
1 89
91 1
1 93
1 95
1 97
99 1
1 101
1 103
1 105
107 1
109 1
111 1
1 113
...

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 q=100000

Test #73:

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

input:

99970 100000
2 1
3 1
5 1
7 1
1 9
1 11
1 13
15 1
1 17
19 1
21 1
23 1
1 25
27 1
29 1
1 31
33 1
1 35
37 1
1 39
1 41
1 43
45 1
47 1
1 49
1 51
53 1
1 55
1 57
59 1
61 1
63 1
65 1
67 1
69 1
1 71
73 1
1 75
1 77
79 1
1 81
1 83
85 1
1 87
89 1
91 1
1 93
1 95
97 1
99 1
1 101
103 1
1 105
1 107
1 109
1 111
113 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 q=100000

Test #74:

score: 0
Accepted
time: 37ms
memory: 269372kb

input:

99970 100000
2 1
3 1
5 1
7 1
9 1
11 1
1 13
1 15
1 17
19 1
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
37 1
39 1
1 41
1 43
1 45
47 1
1 49
51 1
1 53
55 1
57 1
59 1
1 61
63 1
1 65
1 67
1 69
1 71
73 1
75 1
77 1
1 79
1 81
1 83
1 85
1 87
89 1
91 1
93 1
1 95
1 97
1 99
101 1
103 1
1 105
1 107
1 109
111 1
1 113
...

output:

1
2
3
4
49986
0
49987
5
6
7
49988
0
8
0
9
10
49989
0
49990
0
11
12
49991
0
49992
13
49993
14
49994
15
16
17
18
19
49995
20
21
22
23
0
24
25
49996
26
49997
0
49998
27
49999
0
28
29
30
0
31
0
50000
0
50001
0
50002
32
33
34
35
36
50003
0
37
0
38
39
50004
0
50005
40
41
42
43
44
50006
0
50007
45
46
47
48...

result:

ok q=100000

Test #75:

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

input:

99970 100000
2 1
3 1
5 1
7 1
1 9
11 1
13 1
1 15
1 17
1 19
21 1
1 23
25 1
27 1
1 29
1 31
1 33
1 35
37 1
1 39
41 1
43 1
1 45
1 47
1 49
51 1
53 1
1 55
1 57
59 1
1 61
63 1
65 1
1 67
69 1
1 71
73 1
75 1
77 1
79 1
81 1
83 1
85 1
87 1
89 1
91 1
93 1
95 1
1 97
99 1
101 1
103 1
1 105
1 107
1 109
1 111
113 1
...

output:

0
0
0
1
49986
49987
49988
49989
49990
49991
0
2
0
0
49992
49993
3
4
0
0
0
0
0
0
5
6
7
8
9
10
11
49994
12
13
14
15
49995
49996
49997
49998
49999
0
50000
0
0
0
0
50001
0
16
17
18
19
50002
20
21
50003
50004
50005
22
23
24
25
26
27
28
29
30
0
0
31
32
33
34
50006
35
36
37
50007
0
50008
50009
50010
50011
...

result:

ok q=100000

Test #76:

score: 0
Accepted
time: 51ms
memory: 268608kb

input:

99970 100000
1 2
3 1
4 1
1 7
1 10
1 13
16 1
19 1
1 22
25 1
1 28
1 31
34 1
1 37
40 1
1 43
1 46
1 49
52 1
1 55
1 58
61 1
64 1
1 67
70 1
73 1
76 1
1 79
82 1
1 85
88 1
1 91
1 94
97 1
100 1
1 103
106 1
109 1
112 1
115 1
118 1
1 121
124 1
1 127
130 1
1 133
1 136
139 1
1 142
1 145
1 148
1 151
1 154
1 157
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 q=100000

Test #77:

score: 0
Accepted
time: 60ms
memory: 270380kb

input:

99970 100000
3 1
1 4
1 7
1 10
1 13
16 1
1 19
1 22
1 25
1 28
1 31
34 1
1 37
40 1
43 1
46 1
1 49
1 52
1 55
58 1
1 61
64 1
67 1
70 1
1 73
1 76
79 1
1 82
85 1
1 88
91 1
94 1
1 97
1 100
1 103
106 1
109 1
1 112
115 1
1 118
121 1
1 124
127 1
130 1
1 133
136 1
139 1
142 1
1 145
1 148
151 1
1 154
157 1
1 160...

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 q=100000

Test #78:

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

input:

99970 100000
3 1
1 4
1 7
1 10
1 13
16 1
19 1
22 1
25 1
1 28
1 31
1 34
1 37
1 40
1 43
46 1
49 1
1 52
55 1
1 58
1 61
1 64
67 1
70 1
1 73
76 1
1 79
1 82
1 85
88 1
1 91
94 1
97 1
100 1
1 103
1 106
1 109
1 112
1 115
118 1
121 1
1 124
127 1
130 1
1 133
1 136
139 1
142 1
145 1
148 1
1 151
154 1
1 157
1 160...

output:

1
0
33325
2
66648
0
33326
33327
33328
3
33329
4
33330
33331
33332
0
5
6
7
8
9
33333
10
33334
11
12
33335
13
33336
14
33337
15
16
17
18
19
20
33338
33339
21
33340
33341
22
23
24
25
33342
33343
26
27
28
29
66649
33344
66650
33345
66651
33346
33347
33348
30
31
32
0
33349
0
33
34
35
33350
66652
0
66653
...

result:

ok q=100000

Test #79:

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

input:

99970 100000
1 2
3 1
4 1
7 1
1 10
1 13
16 1
1 19
22 1
25 1
1 28
1 31
1 34
1 37
40 1
1 43
1 46
1 49
1 52
55 1
1 58
61 1
64 1
67 1
70 1
1 73
76 1
79 1
82 1
85 1
88 1
91 1
94 1
1 97
1 100
103 1
106 1
109 1
1 112
115 1
1 118
1 121
124 1
127 1
130 1
1 133
136 1
1 139
1 142
1 145
1 148
151 1
154 1
1 157
1...

output:

2
1
3
4
0
0
0
0
0
0
5
6
0
0
0
0
0
0
0
33326
7
8
9
10
11
12
13
33327
33328
33329
33330
33331
14
15
16
17
18
19
20
21
22
23
33332
33333
33334
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
0
0
41
42
43
44
45
0
33335
0
66648
0
0
33336
33337
33338
33339
33340
33341
33342
33343
33344
46
33345
47
48
3...

result:

ok q=100000

Test #80:

score: 0
Accepted
time: 35ms
memory: 270172kb

input:

99970 100000
1 2
1 4
5 1
9 1
13 1
1 17
21 1
1 25
1 29
33 1
1 37
41 1
45 1
1 49
1 53
1 57
1 61
65 1
1 69
1 73
1 77
81 1
85 1
89 1
1 93
97 1
101 1
105 1
109 1
113 1
1 117
121 1
1 125
1 129
133 1
137 1
141 1
1 145
149 1
1 153
157 1
161 1
165 1
1 169
1 173
177 1
181 1
185 1
189 1
193 1
1 197
1 201
1 205...

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 q=100000

Test #81:

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

input:

99970 100000
1 2
1 4
5 1
9 1
13 1
17 1
21 1
1 25
1 29
1 33
37 1
1 41
1 45
1 49
53 1
1 57
1 61
1 65
1 69
73 1
77 1
81 1
1 85
89 1
93 1
97 1
101 1
105 1
1 109
1 113
1 117
121 1
1 125
129 1
133 1
137 1
141 1
145 1
1 149
1 153
1 157
1 161
1 165
169 1
173 1
177 1
181 1
185 1
1 189
1 193
1 197
201 1
1 205...

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 q=100000

Test #82:

score: 0
Accepted
time: 40ms
memory: 268928kb

input:

99970 100000
4 1
1 5
9 1
1 13
17 1
1 21
25 1
29 1
33 1
37 1
41 1
1 45
1 49
53 1
57 1
61 1
1 65
69 1
1 73
77 1
1 81
85 1
89 1
1 93
1 97
1 101
105 1
109 1
113 1
1 117
121 1
1 125
129 1
133 1
1 137
141 1
145 1
149 1
153 1
1 157
161 1
165 1
1 169
1 173
1 177
181 1
185 1
189 1
193 1
1 197
201 1
205 1
209...

output:

24995
1
24994
24996
74979
0
49988
0
2
3
74980
0
4
5
6
0
7
8
9
10
11
49989
74981
0
49990
24997
49991
0
24998
24999
25000
25001
74982
0
12
13
14
15
16
17
18
49992
49993
49994
49995
0
49996
19
20
21
22
23
25002
25003
49997
24
25
25004
25005
26
27
28
29
30
31
32
33
34
35
25006
36
37
38
39
40
41
42
25007...

result:

ok q=100000

Test #83:

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

input:

99970 100000
4 1
5 1
1 9
13 1
17 1
21 1
25 1
29 1
33 1
37 1
41 1
45 1
1 49
53 1
1 57
61 1
65 1
69 1
1 73
1 77
1 81
85 1
1 89
93 1
97 1
1 101
1 105
1 109
1 113
117 1
121 1
1 125
1 129
1 133
1 137
1 141
1 145
1 149
153 1
157 1
1 161
165 1
169 1
1 173
1 177
181 1
1 185
189 1
1 193
1 197
1 201
205 1
1 2...

output:

49987
2
1
24994
24995
74979
0
0
3
4
0
49988
49989
5
6
7
24996
24997
24998
24999
25000
49990
49991
8
9
10
11
12
13
14
15
16
25001
25002
25003
25004
25005
25006
25007
17
25008
25009
18
19
20
21
22
25010
25011
25012
25013
25014
25015
49992
49993
49994
23
24
49995
49996
25
26
49997
49998
27
28
29
30
31
...

result:

ok q=100000

Test #84:

score: 0
Accepted
time: 39ms
memory: 270160kb

input:

99970 100000
1 2
4 1
6 1
11 1
1 16
21 1
26 1
31 1
36 1
1 41
46 1
1 51
56 1
61 1
66 1
1 71
1 76
81 1
86 1
1 91
96 1
101 1
106 1
111 1
1 116
121 1
126 1
1 131
136 1
1 141
1 146
1 151
1 156
1 161
1 166
171 1
176 1
181 1
186 1
1 191
1 196
1 201
206 1
211 1
216 1
221 1
226 1
1 231
1 236
241 1
246 1
251 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 q=100000

Test #85:

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

input:

99970 100000
1 2
3 1
6 1
1 11
1 16
21 1
1 26
1 31
1 36
1 41
46 1
1 51
56 1
61 1
1 66
1 71
76 1
1 81
86 1
91 1
1 96
1 101
1 106
111 1
1 116
121 1
126 1
131 1
136 1
1 141
1 146
1 151
1 156
1 161
166 1
171 1
176 1
1 181
186 1
1 191
1 196
201 1
206 1
1 211
216 1
221 1
226 1
231 1
236 1
241 1
246 1
251 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 q=100000

Test #86:

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

input:

99970 100000
3 1
4 1
5 1
1 6
11 1
1 16
1 21
1 26
1 31
36 1
1 41
46 1
1 51
1 56
1 61
66 1
1 71
1 76
81 1
1 86
91 1
96 1
1 101
106 1
111 1
1 116
121 1
126 1
131 1
136 1
141 1
146 1
151 1
1 156
1 161
166 1
1 171
1 176
181 1
186 1
191 1
1 196
201 1
206 1
1 211
216 1
221 1
226 1
231 1
236 1
1 241
246 1
2...

output:

59984
1
39991
2
59985
3
19997
19998
4
5
6
7
8
9
59986
39992
59987
10
11
12
13
14
79978
15
16
17
18
19
20
19999
20000
20001
21
22
79979
20002
79980
23
24
59988
25
26
27
39993
79981
39994
20003
20004
20005
39995
39996
28
29
30
31
0
32
33
34
35
36
37
38
39
40
59989
59990
20006
20007
20008
41
42
43
2000...

result:

ok q=100000

Test #87:

score: 0
Accepted
time: 35ms
memory: 268860kb

input:

99970 100000
1 3
5 1
6 1
1 11
1 16
1 21
1 26
31 1
1 36
41 1
1 46
51 1
56 1
1 61
1 66
1 71
76 1
81 1
1 86
1 91
1 96
1 101
1 106
111 1
116 1
1 121
1 126
1 131
136 1
1 141
1 146
151 1
1 156
161 1
1 166
171 1
1 176
181 1
1 186
1 191
196 1
1 201
1 206
1 211
216 1
1 221
1 226
1 231
236 1
241 1
246 1
1 251...

output:

39990
1
0
19996
19997
19998
19999
20000
0
0
0
0
0
20001
2
59984
3
4
5
6
7
8
9
10
11
12
13
20002
20003
20004
20005
20006
20007
20008
20009
20010
0
20011
20012
20013
20014
14
15
20015
20016
20017
20018
20019
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
20020
20021
2...

result:

ok q=100000

Test #88:

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

input:

99970 100000
1 3
1 4
1 5
1 6
7 1
1 13
1 19
25 1
31 1
1 37
1 43
49 1
55 1
1 61
1 67
1 73
79 1
85 1
91 1
1 97
103 1
109 1
115 1
121 1
1 127
133 1
139 1
145 1
1 151
157 1
1 163
169 1
1 175
181 1
1 187
1 193
1 199
1 205
1 211
1 217
223 1
229 1
1 235
1 241
1 247
253 1
259 1
1 265
271 1
277 1
1 283
1 289
...

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 q=100000

Test #89:

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

input:

99970 100000
3 1
1 4
5 1
6 1
7 1
13 1
19 1
1 25
1 31
37 1
43 1
1 49
1 55
1 61
1 67
73 1
1 79
1 85
1 91
1 97
1 103
109 1
115 1
121 1
127 1
133 1
139 1
1 145
151 1
1 157
1 163
1 169
1 175
1 181
187 1
1 193
1 199
1 205
1 211
1 217
223 1
229 1
235 1
1 241
247 1
1 253
1 259
1 265
1 271
1 277
1 283
289 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 q=100000

Test #90:

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

input:

99970 100000
1 2
1 3
1 4
7 1
13 1
1 19
25 1
31 1
37 1
1 43
1 49
55 1
61 1
1 67
73 1
1 79
85 1
1 91
97 1
1 103
109 1
115 1
121 1
1 127
1 133
139 1
1 145
1 151
1 157
1 163
169 1
1 175
181 1
187 1
1 193
1 199
205 1
1 211
1 217
1 223
229 1
1 235
1 241
1 247
253 1
1 259
1 265
271 1
1 277
1 283
289 1
1 29...

output:

66652
49989
16665
1
2
49990
33327
3
83313
0
49991
49992
33328
33329
33330
16666
16667
16668
16669
16670
16671
4
5
6
7
16672
16673
8
9
33331
33332
49993
49994
0
83314
16674
16675
16676
83315
66653
66654
0
49995
49996
49997
49998
33333
16677
16678
33334
33335
10
11
12
16679
16680
16681
16682
16683
166...

result:

ok q=100000

Test #91:

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

input:

99970 100000
3 1
6 1
1 7
13 1
19 1
25 1
1 31
1 37
1 43
1 49
55 1
61 1
67 1
1 73
1 79
1 85
1 91
97 1
103 1
109 1
1 115
121 1
127 1
133 1
139 1
145 1
151 1
157 1
163 1
169 1
175 1
181 1
187 1
193 1
199 1
205 1
1 211
217 1
223 1
229 1
1 235
1 241
247 1
1 253
259 1
265 1
271 1
277 1
1 283
1 289
295 1
1 ...

output:

16666
33329
33328
1
2
16665
16664
3
4
5
6
49991
7
8
9
33330
33331
33332
33333
33334
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
16667
16668
33335
33336
49992
49993
49994
49995
30
31
32
33
34
35
36
37
33337
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
33338
33339
33340
16669
166...

result:

ok q=100000

Test #92:

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

input:

99970 100000
3 1
1 4
5 1
1 8
15 1
22 1
1 29
1 36
1 43
50 1
1 57
1 64
71 1
78 1
1 85
1 92
99 1
1 106
1 113
1 120
1 127
1 134
1 141
1 148
1 155
162 1
169 1
176 1
1 183
190 1
197 1
1 204
1 211
218 1
225 1
232 1
239 1
1 246
1 253
260 1
1 267
274 1
1 281
288 1
295 1
302 1
309 1
316 1
1 323
330 1
1 337
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 q=100000

Test #93:

score: 0
Accepted
time: 60ms
memory: 270116kb

input:

99970 100000
1 3
1 5
6 1
7 1
1 8
15 1
22 1
29 1
36 1
1 43
50 1
57 1
64 1
1 71
1 78
1 85
92 1
1 99
106 1
113 1
1 120
127 1
134 1
141 1
148 1
155 1
1 162
169 1
176 1
1 183
190 1
197 1
204 1
211 1
1 218
1 225
232 1
239 1
246 1
1 253
1 260
267 1
274 1
1 281
1 288
1 295
1 302
1 309
316 1
323 1
1 330
337 ...

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 q=100000

Test #94:

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

input:

99970 100000
2 1
1 3
1 5
1 7
8 1
15 1
1 22
1 29
36 1
43 1
50 1
57 1
1 64
1 71
78 1
85 1
1 92
1 99
106 1
113 1
120 1
127 1
134 1
141 1
1 148
1 155
162 1
169 1
1 176
1 183
190 1
197 1
204 1
1 211
218 1
225 1
1 232
239 1
1 246
253 1
1 260
267 1
274 1
1 281
288 1
1 295
302 1
1 309
1 316
1 323
330 1
337 ...

output:

42854
42853
28571
28570
14287
3
14288
4
2
1
14289
5
14286
28572
6
7
8
9
10
11
12
13
14
15
16
17
42855
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
57135
14302
14303
14304
14305
14306
14307
42856
18
19
71415
14308
14309
20
21
14310
14311
14312
14313
14314
14315
14316
28573
...

result:

ok q=100000

Test #95:

score: 0
Accepted
time: 39ms
memory: 269144kb

input:

99970 100000
2 1
3 1
4 1
1 6
7 1
8 1
1 15
1 22
29 1
1 36
1 43
50 1
1 57
1 64
71 1
78 1
1 85
1 92
1 99
106 1
113 1
1 120
1 127
1 134
141 1
1 148
155 1
1 162
1 169
176 1
1 183
1 190
197 1
1 204
1 211
218 1
1 225
1 232
239 1
246 1
253 1
1 260
267 1
1 274
281 1
1 288
1 295
1 302
1 309
1 316
323 1
330 1
...

output:

0
0
57134
42853
5
28570
42852
2
14288
4
71415
71416
28571
28572
28573
28574
28575
28576
71417
71418
71419
71420
71421
71422
71423
14287
3
1
6
7
8
9
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28...

result:

ok q=100000

Test #96:

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

input:

99970 100000
2 1
3 1
4 1
1 5
1 6
9 1
17 1
25 1
33 1
1 41
49 1
57 1
65 1
73 1
1 81
89 1
1 97
1 105
113 1
1 121
1 129
137 1
145 1
153 1
1 161
1 169
1 177
1 185
1 193
1 201
1 209
217 1
1 225
1 233
1 241
1 249
1 257
1 265
1 273
281 1
1 289
297 1
1 305
313 1
321 1
1 329
337 1
1 345
1 353
361 1
369 1
1 37...

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 q=100000

Test #97:

score: 0
Accepted
time: 35ms
memory: 269948kb

input:

99970 100000
1 2
1 4
1 5
1 6
1 9
1 17
25 1
33 1
41 1
1 49
57 1
1 65
1 73
81 1
89 1
97 1
1 105
113 1
1 121
129 1
137 1
145 1
1 153
161 1
169 1
1 177
185 1
193 1
1 201
209 1
217 1
1 225
1 233
1 241
249 1
257 1
1 265
273 1
281 1
289 1
297 1
305 1
1 313
321 1
329 1
337 1
345 1
353 1
1 361
369 1
377 1
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 q=100000

Test #98:

score: 0
Accepted
time: 20ms
memory: 270404kb

input:

99970 100000
4 1
5 1
1 8
1 9
17 1
25 1
1 33
1 41
1 49
57 1
65 1
1 73
1 81
1 89
97 1
105 1
1 113
1 121
1 129
137 1
145 1
1 153
1 161
169 1
177 1
185 1
1 193
1 201
1 209
217 1
1 225
1 233
241 1
1 249
1 257
265 1
1 273
1 281
289 1
297 1
305 1
1 313
1 321
329 1
337 1
345 1
1 353
1 361
1 369
377 1
1 385
...

output:

37499
12504
12501
12503
3
37498
25002
49995
2
12502
1
37500
62491
25001
49996
62492
4
5
6
7
12500
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
12505
12506
12507
23
24
25
26
27
28
29
25003
30
31
32
33
34
35
36
37
38
39
40
41
42
43
12508
12509
12510
74987
74988
12511
12512
12513
44
45
46
47
48
12514
125...

result:

ok q=100000

Test #99:

score: 0
Accepted
time: 35ms
memory: 268644kb

input:

99970 100000
6 1
9 1
1 17
1 25
1 33
41 1
1 49
1 57
1 65
73 1
1 81
89 1
97 1
1 105
113 1
1 121
129 1
137 1
1 145
1 153
1 161
169 1
1 177
1 185
1 193
201 1
209 1
217 1
1 225
1 233
1 241
249 1
257 1
265 1
1 273
281 1
1 289
1 297
1 305
313 1
321 1
1 329
337 1
345 1
353 1
361 1
369 1
1 377
1 385
393 1
1 ...

output:

0
0
0
49993
37496
74986
62489
12502
12503
62490
25000
1
12499
12500
12501
62491
62492
2
3
62493
62494
74987
62495
62496
62497
62498
62499
37497
74988
74989
37498
4
5
6
7
8
9
10
11
12
12498
13
14
15
16
17
18
19
37499
37500
37501
37502
37503
37504
37505
25001
25002
25003
12504
12505
12506
12507
12508
...

result:

ok q=100000

Test #100:

score: 0
Accepted
time: 37ms
memory: 36016kb

input:

10000 100000
62 1
1 552
818 1
1 1204
1993 1
1 4007
1 4095
5262 1
1 5367
5784 1
1 6036
6091 1
1 6559
8108 1
1 8154
1 9191
9482 1
41 2
2 294
1572 2
1852 2
2 1895
3322 2
4360 2
4905 2
2 5027
5934 2
6198 2
6504 2
2 6870
8364 2
722 3
812 3
1347 3
1856 3
1990 3
2008 3
2578 3
3 3019
3 3248
3 3495
3 3616
3 ...

output:

97511

result:

ok q=100000

Test #101:

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

input:

10000 100000
1 278
1 1411
1906 1
2107 1
2178 1
1 2299
2526 1
1 2856
1 3613
3796 1
1 4128
1 4196
1 4250
1 4631
5135 1
5224 1
1 5279
6206 1
1 6985
1 7310
1 7357
7722 1
7815 1
1 8282
9362 1
9571 1
1 9782
1 9999
874 2
2 1055
1187 2
2010 2
2 2173
2250 2
2511 2
2699 2
2756 2
2876 2
2 3802
4047 2
4937 2
2 ...

output:

97091
78479
69168
90014
99317
93793
74276
6993
97763
97762
49617
24869
19170
90703
44917
92578
96363
30594
85699
66429
71186
99660
58312
33751
741
93221
78076
35862
35861
57231
35633
35632
27497
88549
98292
20950
95783
69851
18492
66366
78594
34738
2753
72455
72454
34859
99648
4635
80827
99094
39393...

result:

ok q=100000

Test #102:

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

input:

10000 100000
1 257
1 1150
1 2495
4714 1
5052 1
5128 1
5130 1
1 5235
1 6273
1 7279
7296 1
1 7899
8429 1
8895 1
9133 1
1 9402
2 378
2 434
1060 2
2991 2
5009 2
5316 2
2 5857
2 5984
2 6490
2 6494
6963 2
2 7560
2 7816
7996 2
8202 2
2 8218
2 9608
893 3
3 1127
3 1318
1863 3
3136 3
3 3927
4162 3
4273 3
3 49...

output:

0
75918
80501
88540
96892
91311
77554
88469
95108
95107
693
692
33188
75164
24695
24694
94844
29971
64708
90475
90474
90473
90472
90898
70392
70391
65179
89345
94871
71034
76127
99880
45832
42959
42958
99806
40961
94247
52588
89520
40271
40270
40269
40268
7623
65334
65333
78276
74419
63335
77945
873...

result:

ok q=100000

Test #103:

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

input:

10000 100000
1 32
366 1
1164 1
1 1881
2317 1
2931 1
1 2932
3853 1
4011 1
1 4090
1 5006
5656 1
5696 1
1 6055
6674 1
7367 1
7599 1
8265 1
2 1468
2 1486
1670 2
2375 2
2 2729
3116 2
2 3202
2 3560
2 4047
2 4643
2 4645
4794 2
4958 2
5887 2
5947 2
2 6549
2 6992
2 7179
7436 2
2 7513
2 8130
2 8703
2 9686
514...

output:

0
35207
98628
98627
69871
69870
97713
97476
5416
83807
97812
97811
97810
55284
88554
88553
87960
73532
73531
73530
73529
73528
73527
73526
73525
6668
99148
99147
95934
95933
95932
95931
95331
85887
91153
28379
28378
28377
28376
93492
93491
68959
57623
92007
94853
79459
79458
33724
33723
6373
5010
60...

result:

ok q=100000

Test #104:

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

input:

10000 100000
1 1173
1 2045
1 2146
1 2314
2389 1
1 2586
1 2796
1 3622
3650 1
1 3692
1 3985
4433 1
4520 1
5493 1
1 5514
6563 1
7220 1
1 7472
1 8043
1 8385
8565 1
9622 1
1 9735
2 97
2 131
167 2
1663 2
3416 2
2 4187
2 4386
2 4447
2 5022
5025 2
5179 2
2 5885
2 6919
8335 2
8400 2
2 8671
8807 2
9147 2
3 83...

output:

0
0
0
0
76229
76228
42788
42787
42786
98445
78044
97297
45842
68840
24099
67560
67559
99024
99023
96662
75860
92279
36346
36345
36344
36343
36342
98322
47658
70882
63226
63225
63224
63223
98508
70072
56306
76564
76563
76562
13540
9286
9285
9284
9283
97336
93454
93453
93452
93451
93450
43893
71968
71...

result:

ok q=100000

Test #105:

score: 0
Accepted
time: 23ms
memory: 34100kb

input:

10000 100000
1 380
1 873
1 1618
1838 1
1 2767
3506 1
1 4453
4602 1
4754 1
4880 1
1 5778
1 5811
1 6230
7868 1
1 7911
8126 1
1 8233
9049 1
9356 1
2 10
2 537
658 2
2 1129
1461 2
2 2035
2237 2
3097 2
3513 2
2 3524
2 3931
2 4956
5072 2
2 5204
2 5302
2 5454
2 5562
5607 2
5774 2
2 5909
6017 2
2 6193
6622 2...

output:

0
98980
97705
97512
86398
75549
67374
64431
87702
73365
73364
73363
73362
73361
68526
68525
68524
68523
68522
68521
68520
68519
99496
99495
90007
88561
80501
77032
71836
70262
99898
99897
99690
99474
75691
75690
75689
75688
75687
99895
94660
94659
94658
94657
93116
74085
74084
74083
74082
74081
7408...

result:

ok q=100000

Test #106:

score: 0
Accepted
time: 15ms
memory: 33472kb

input:

10000 100000
1 223
924 1
1010 1
1 2164
1 2599
3130 1
3294 1
1 3555
1 3759
4080 1
1 4841
4948 1
1 5358
1 6539
7363 1
1 7747
9377 1
1 9393
1 9596
1 9941
376 2
2 623
878 2
1665 2
1759 2
2 1941
2135 2
3573 2
3685 2
3843 2
2 4021
5156 2
2 6157
2 6758
6934 2
2 7220
2 7354
7620 2
2 7815
2 8287
2 8564
8772 ...

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 q=100000

Test #107:

score: 0
Accepted
time: 40ms
memory: 38332kb

input:

10000 100000
1 246
483 1
1 766
1 1389
1 1977
1 2314
2563 1
2637 1
2826 1
1 4125
4414 1
4737 1
1 5172
1 5460
1 5727
1 6441
1 6611
1 6654
1 7016
7208 1
1 7265
1 7459
7666 1
1 7680
1 7784
8265 1
8518 1
9031 1
2 1115
2 1194
2 1496
1533 2
2 1578
1655 2
2455 2
2 2537
2785 2
2 3661
2 5953
2 6095
2 6250
728...

output:

87475

result:

ok q=100000

Test #108:

score: 0
Accepted
time: 39ms
memory: 38940kb

input:

10000 100000
1 4
1 262
480 1
1661 1
1942 1
3141 1
3242 1
1 4520
5039 1
5322 1
5617 1
5702 1
6596 1
7549 1
8091 1
1 8150
1 8300
8880 1
8976 1
9057 1
1 9615
2 361
986 2
2 1260
1571 2
1831 2
2903 2
2 3659
2 4398
4775 2
4780 2
2 5425
6353 2
2 6520
2 7157
2 7742
2 8973
9025 2
50 3
3 677
3 816
924 3
1742 ...

output:

83223
94724
94723
84722
26313
86442
96852
50460
99841
69610
57963
91732
97477
54666
80567
95432
47882
34404
88353
43132
99886
99264
98027
56896
74308
75063
51102
96404
84912
33846
77112
77111
44336
44335
74015
92622
89234
77950
99250
88578
88352
88351
88349
93927
93925
24703
98611
23650
97692
27378
...

result:

ok q=100000

Test #109:

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

input:

10000 100000
637 1
1879 1
1 2512
1 3578
3828 1
4117 1
1 4420
4468 1
4698 1
1 6029
6048 1
6553 1
6615 1
1 6970
7457 1
7626 1
1 7647
1 9559
9862 1
2 362
2 2514
2764 2
2 2982
3679 2
6566 2
2 8237
8441 2
8654 2
8754 2
8796 2
2 8905
9184 2
3 1285
3 1795
2932 3
3 3025
3 3149
3 3537
5987 3
3 6361
3 6710
3 ...

output:

99312
98593
81049
81047
98045
78372
91864
48088
85550
83542
73496
84976
84971
86743
86738
81143
79993
79593
90593
84297
72830
99765
89945
99557
99556
53463
87177
60538
87038
87036
69828
37547
93046
61832
30281
27956
46763
82490
98046
25565
2359
76389
5729
1423
82830
94511
76559
76558
24120
24118
782...

result:

ok q=100000

Test #110:

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

input:

10000 100000
6 1
1 399
891 1
1 1247
1269 1
1 1839
1 4072
4089 1
1 4245
1 4901
5339 1
1 7182
7459 1
8149 1
8208 1
1 8881
8937 1
1 9259
2 997
2 1065
2 2100
2 2796
2 3802
2 4857
2 5518
2 5539
5952 2
2 5973
7487 2
2 8574
2 9917
61 3
3 70
591 3
3 594
3 1502
3 1606
3 1616
3106 3
3 3523
3 3742
3 4162
4550 ...

output:

98767
98765
45943
27473
89288
89287
72840
72839
72838
85186
62949
62947
62946
85924
73156
73155
73154
73151
73150
73149
73147
11969
98795
98274
27355
27353
95950
93811
93749
90163
72314
71459
71445
36104
98953
91655
91653
88737
98175
24757
24756
24755
24754
96063
87939
98676
96121
93795
85923
97744
...

result:

ok q=100000

Test #111:

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

input:

10000 100000
1 362
793 1
1 2340
1 2929
1 3619
1 3663
1 3789
6135 1
6331 1
6700 1
1 6901
7815 1
8192 1
1 8615
8676 1
1 8849
1 9273
1 9310
323 2
512 2
2 847
2 967
2 970
1006 2
1716 2
2102 2
2 2739
3298 2
2 3444
2 3472
3889 2
2 4569
2 5985
6892 2
7135 2
7675 2
7854 2
7871 2
8179 2
8656 2
8719 2
2 8799
...

output:

80798
99873
55875
35469
24762
23873
97315
97017
97108
99881
99530
99428
98340
83682
93388
87738
84765
72523
67203
86337
86336
86333
84671
82774
60545
60543
52014
52013
130
129
73624
9217
9216
9215
94043
94042
90028
76323
70508
70507
70506
70504
70501
93347
84026
73465
68349
64727
49075
39145
67079
6...

result:

ok q=100000

Test #112:

score: 0
Accepted
time: 16ms
memory: 34228kb

input:

10000 100000
1 53
1 1122
1949 1
1965 1
1 2760
1 6345
6354 1
1 6764
1 7825
1 8453
8734 1
9046 1
1 9160
9875 1
2 29
167 2
754 2
2 867
1007 2
1040 2
2 1421
2752 2
2 3046
2 3444
2 3627
2 4830
2 5453
2 6492
2 8157
2 8480
2 9226
2 9460
9525 2
369 3
572 3
3 648
1053 3
3 1356
3 2369
3153 3
3155 3
3 5471
604...

output:

53495
53492
53489
98240
76653
72165
71709
69994
45946
53488
26676
44227
44226
44225
44224
44223
44220
44219
44218
44216
30032
99313
74682
21430
63820
63324
91572
91571
91570
91569
90850
89035
87687
81591
77520
68564
56351
54083
46890
55641
95487
92931
88136
66906
59106
59105
59104
97867
96771
96499
...

result:

ok q=100000

Test #113:

score: 0
Accepted
time: 18ms
memory: 34388kb

input:

10000 100000
303 1
1 306
1 309
603 1
1 624
1 713
1 954
1019 1
1921 1
2013 1
1 2239
2768 1
1 2899
4285 1
4773 1
1 5281
1 5596
5739 1
5755 1
5849 1
6228 1
1 7029
1 7255
7597 1
7679 1
9099 1
1 9342
966 2
2 1630
2 1984
2339 2
2 2603
2 3021
2 3661
2 3766
6428 2
2 7230
2 7652
7773 2
7997 2
9437 2
9475 2
9...

output:

2068
2066
2064
2063
2062
2059
2055
1237
43131
43128
43127
43124
20023
15850
13526
4322
69796
69795
69793
69791
69790
63270
62327
56004
36333
44972
44971
44969
44968
44967
44965
32011
98873
98488
76231
62676
47208
31657
29651
13583
5099
99841
97269
96803
90137
77913
64722
52102
40928
17942
7178
5878
...

result:

ok q=100000

Test #114:

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

input:

10000 100000
1 687
1 2238
2339 1
2540 1
3744 1
1 4048
1 5868
1 6041
7833 1
8786 1
9222 1
935 2
2 1185
2 1659
1973 2
2 2048
2 2569
3163 2
3286 2
2 4612
5511 2
2 5535
5942 2
2 6222
2 6365
2 6547
6954 2
2 7976
8670 2
9133 2
2 9507
1116 3
1283 3
3 1886
3 2675
4460 3
5444 3
3 6072
3 7681
8072 3
8104 3
3 ...

output:

99727

result:

ok q=100000

Test #115:

score: 0
Accepted
time: 39ms
memory: 38796kb

input:

10000 100000
16 1
1 226
1 546
1 751
1 1332
1 2446
2702 1
2853 1
4522 1
4669 1
1 4771
1 5035
5108 1
1 5221
1 5265
5519 1
8583 1
1 8612
1 9249
1 9798
20 2
2 312
534 2
689 2
1484 2
2304 2
2351 2
2 3520
2 3886
4324 2
4432 2
4630 2
4977 2
6737 2
7547 2
2 7610
2 7638
7669 2
7678 2
7894 2
2 8781
2 8824
904...

output:

72104
72103
59025
92150
99946
67347
87261
90424
95075
33909
33908
50492
75884
96222
82342
15663
47850
91874
91873
7370
88934
69182
57950
67807
98375
37641
54680
76560
3347
96694
61549
77337
77336
96147
47485
22349
88775
81341
89991
67359
96689
97646
99381
98937
98763
61789
71847
71846
23817
95291
65...

result:

ok q=100000

Test #116:

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

input:

10000 100000
1 634
1 773
973 1
1993 1
1 2206
1 2258
1 2674
2934 1
3289 1
1 3486
1 3665
3870 1
1 4202
1 4222
4916 1
1 5131
5341 1
1 5589
1 7234
1 7419
1 7603
1 7647
1 7871
1 7887
8704 1
2 165
2 334
2 896
2 1110
1438 2
1649 2
1824 2
2158 2
2 2205
2781 2
2 2912
2 4077
2 4501
4528 2
2 5391
2 5496
2 5811...

output:

0
68732
67028
86972
58360
58359
58358
58357
58356
99856
23684
49744
49743
49742
43258
53354
53353
53352
99210
13722
58759
83541
83540
89760
24730
99520
97413
96756
11399
80067
80284
99287
38934
80687
80686
80685
91200
92158
92157
91066
97975
34225
34224
99931
79633
93628
60092
69621
85002
79899
7989...

result:

ok q=100000

Test #117:

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

input:

10000 100000
141 1
1 864
1 1515
1 1659
1 1665
1 1986
1 2432
2546 1
1 2598
1 2721
2792 1
3557 1
3736 1
1 7164
7510 1
1 9187
9424 1
2 2738
2 2936
3033 2
2 4575
4971 2
2 5719
6196 2
2 6465
2 6500
2 6665
2 7093
7520 2
2 7675
2 9723
3 130
3 279
755 3
3 964
1475 3
1750 3
3 1879
3 1961
3 2223
3 3125
3 3484...

output:

0
96341
6148
93837
56819
56818
56817
94673
97199
97198
94575
94574
98334
99379
83279
83278
98973
65685
65684
65683
84797
84796
85293
85292
50365
50364
50363
50362
50361
50360
50359
50358
68553
19477
18127
18126
89742
28989
28988
28987
36007
36006
17478
99881
13136
75045
75044
75043
62891
62890
62889...

result:

ok q=100000

Test #118:

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

input:

10000 100000
1 496
1 976
1674 1
1 2091
1 2796
1 3047
1 3734
1 4361
1 4620
6855 1
1 6896
1 8073
8352 1
1 8572
8781 1
1 8857
1 8915
1 9035
1 9294
9490 1
9985 1
673 2
855 2
2 1012
1711 2
2 1902
2426 2
2 2597
2960 2
2 4925
2 5659
7946 2
7990 2
2 8450
2 8638
2 8646
2 8918
9379 2
3 443
3 458
3 1247
3 1405...

output:

29979
29978
84573
58946
58945
58944
58943
92507
92506
92505
11220
11219
11218
11217
84516
97785
95431
94786
99136
99135
99119
84490
71076
87281
87280
81168
81167
81166
76522
76521
81888
81887
81886
81885
81884
97369
97368
42646
44875
35251
35250
35249
85764
85763
85762
85761
99583
99332
99132
66774
...

result:

ok q=100000

Test #119:

score: 0
Accepted
time: 20ms
memory: 32712kb

input:

10000 100000
155 1
1 312
458 1
1 1772
1 2247
2334 1
1 2939
1 3031
4298 1
1 4460
1 6773
6873 1
7230 1
7285 1
7408 1
8385 1
1 8469
1 9022
9310 1
245 2
883 2
2 1068
1159 2
2 1844
2 2177
2 2407
2670 2
2820 2
2 2948
3701 2
3801 2
2 4259
2 4406
4662 2
5265 2
2 6295
7931 2
9316 2
2 9595
88 3
125 3
1259 3
3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
42535
42534
53540
53539
53538
53537
53536
53535
53534
53533
53532
53531
98780
98406
94466
85708
13776
13775
13774
13773
13772
13771
13770
13769
13768
13767
13766
13765
13764
85837
85836
85835
85834
85833
85832
85831
85830
82550
58553
58552
58551
58550
58549
58548
98525
9788...

result:

ok q=100000

Test #120:

score: 0
Accepted
time: 18ms
memory: 34228kb

input:

10000 100000
121 1
1 242
1 1247
1325 1
1 1445
2211 1
2687 1
3212 1
1 3458
1 4405
1 4473
5781 1
1 5987
6973 1
7680 1
1 9000
9059 1
1 9514
9600 1
51 2
2 693
1286 2
1391 2
2 1705
2 3339
3471 2
2 3864
2 5097
2 5130
5658 2
2 6647
6819 2
2 7138
2 7764
2 7810
8298 2
2 8369
8894 2
2 9880
3 53
3 625
3 779
14...

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 q=100000

Test #121:

score: 0
Accepted
time: 21ms
memory: 57312kb

input:

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

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 q=100000

Test #122:

score: 0
Accepted
time: 36ms
memory: 57316kb

input:

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

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 q=100000

Test #123:

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

input:

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

output:

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

result:

ok q=100000

Test #124:

score: 0
Accepted
time: 17ms
memory: 56192kb

input:

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

output:

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

result:

ok q=100000

Test #125:

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

input:

9970 100000
1 2
3 1
1 5
7 1
1 9
11 1
1 13
15 1
17 1
19 1
21 1
1 23
25 1
1 27
1 29
1 31
1 33
35 1
37 1
39 1
1 41
43 1
45 1
47 1
1 49
1 51
1 53
1 55
1 57
1 59
61 1
1 63
65 1
1 67
69 1
71 1
1 73
1 75
77 1
1 79
1 81
83 1
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
101 1
1 103
1 105
1 107
109 1
111 1
113 1
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 q=100000

Test #126:

score: 0
Accepted
time: 34ms
memory: 56776kb

input:

9970 100000
2 1
3 1
5 1
1 7
9 1
1 11
13 1
1 15
17 1
19 1
1 21
23 1
1 25
1 27
29 1
1 31
33 1
35 1
37 1
1 39
41 1
43 1
1 45
1 47
49 1
1 51
53 1
55 1
1 57
1 59
61 1
63 1
1 65
1 67
1 69
1 71
73 1
1 75
1 77
79 1
1 81
1 83
1 85
87 1
89 1
91 1
93 1
95 1
1 97
1 99
1 101
103 1
105 1
107 1
109 1
111 1
1 113
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 q=100000

Test #127:

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

input:

9970 100000
1 2
1 3
1 5
1 7
9 1
11 1
13 1
1 15
1 17
19 1
1 21
1 23
25 1
1 27
1 29
1 31
1 33
35 1
37 1
1 39
41 1
1 43
45 1
1 47
1 49
51 1
53 1
55 1
1 57
59 1
1 61
1 63
1 65
1 67
1 69
1 71
1 73
75 1
77 1
79 1
1 81
83 1
85 1
87 1
89 1
1 91
93 1
1 95
97 1
1 99
101 1
103 1
1 105
1 107
1 109
111 1
1 113
1...

output:

1
0
4986
2
3
4
5
0
4987
6
4988
7
8
9
10
0
4989
0
4990
0
4991
11
4992
12
4993
13
4994
0
4995
0
14
15
4996
16
17
0
4997
18
19
0
20
21
22
0
23
24
4998
25
4999
26
27
0
5000
0
5001
0
5002
0
5003
0
28
29
30
0
31
0
32
33
5004
34
35
36
37
38
5005
0
5006
0
5007
39
40
41
42
43
44
0
5008
0
5009
45
46
47
5010
0...

result:

ok q=100000

Test #128:

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

input:

9970 100000
1 2
1 3
1 5
7 1
1 9
1 11
1 13
1 15
17 1
1 19
21 1
23 1
25 1
1 27
1 29
1 31
33 1
35 1
1 37
39 1
1 41
1 43
1 45
47 1
49 1
1 51
53 1
1 55
57 1
59 1
61 1
63 1
65 1
67 1
1 69
1 71
1 73
1 75
1 77
79 1
81 1
1 83
85 1
87 1
1 89
1 91
93 1
1 95
1 97
1 99
101 1
103 1
1 105
107 1
109 1
1 111
1 113
1...

output:

0
0
0
0
1
4986
4987
4988
2
3
4989
4
5
4990
4991
4992
0
6
7
4993
4994
8
9
10
11
12
13
14
15
16
17
18
0
19
0
4995
4996
20
21
0
0
22
23
24
4997
0
4998
0
0
25
26
0
0
0
0
0
0
27
28
29
30
31
32
33
34
4999
5000
5001
5002
0
0
35
36
37
38
0
39
0
40
41
42
43
44
5003
5004
5005
45
46
47
48
49
50
51
52
53
54
55
...

result:

ok q=100000

Test #129:

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

input:

9970 100000
3 1
1 4
7 1
1 10
13 1
16 1
1 19
22 1
25 1
1 28
31 1
1 34
37 1
1 40
43 1
1 46
49 1
52 1
1 55
58 1
1 61
1 64
1 67
1 70
73 1
1 76
1 79
1 82
1 85
1 88
91 1
94 1
97 1
100 1
103 1
1 106
109 1
112 1
1 115
1 118
121 1
124 1
1 127
130 1
133 1
136 1
139 1
1 142
145 1
1 148
1 151
1 154
1 157
160 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 q=100000

Test #130:

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

input:

9970 100000
3 1
1 4
7 1
10 1
13 1
1 16
19 1
1 22
25 1
1 28
1 31
1 34
1 37
1 40
43 1
1 46
1 49
1 52
1 55
1 58
1 61
1 64
1 67
1 70
73 1
1 76
79 1
1 82
1 85
1 88
1 91
1 94
1 97
1 100
1 103
1 106
1 109
1 112
1 115
118 1
1 121
124 1
127 1
130 1
1 133
1 136
1 139
1 142
1 145
1 148
151 1
154 1
1 157
1 160
...

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 q=100000

Test #131:

score: 0
Accepted
time: 15ms
memory: 58224kb

input:

9970 100000
2 1
3 1
1 4
1 7
10 1
1 13
1 16
19 1
22 1
25 1
1 28
1 31
1 34
37 1
1 40
1 43
1 46
49 1
1 52
1 55
1 58
1 61
1 64
67 1
1 70
73 1
1 76
1 79
82 1
1 85
1 88
91 1
94 1
97 1
100 1
1 103
1 106
109 1
1 112
115 1
118 1
121 1
1 124
1 127
1 130
133 1
1 136
139 1
1 142
145 1
1 148
1 151
1 154
1 157
16...

output:

2
1
6648
3
6649
3326
6650
0
3327
3328
3329
4
5
3330
3331
6
3332
7
3333
3334
6651
8
6652
3335
3336
9
10
11
6653
0
6654
12
13
14
15
16
17
18
3337
19
3338
0
6655
3339
3340
0
6656
0
3341
20
3342
21
3343
22
23
3344
24
25
26
3345
3346
0
3347
3348
6657
3349
3350
27
28
0
3351
0
3352
29
30
31
32
33
34
3353
3...

result:

ok q=100000

Test #132:

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

input:

9970 100000
1 2
1 3
4 1
7 1
1 10
13 1
16 1
1 19
22 1
25 1
1 28
1 31
1 34
1 37
40 1
43 1
46 1
1 49
1 52
1 55
1 58
1 61
64 1
1 67
70 1
1 73
76 1
1 79
82 1
1 85
1 88
91 1
1 94
1 97
1 100
1 103
1 106
109 1
1 112
1 115
118 1
121 1
124 1
127 1
130 1
133 1
1 136
1 139
142 1
145 1
1 148
151 1
1 154
1 157
1 ...

output:

2
1
6648
3326
6649
6650
0
0
3327
3328
3329
3
3330
3331
3332
3333
4
3334
3335
3336
3337
3338
5
6
7
8
9
10
11
12
13
14
15
3339
16
17
18
19
20
21
22
23
24
3340
6651
6652
0
0
3341
25
3342
3343
3344
3345
3346
3347
3348
3349
6653
26
27
28
29
0
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
3350
3351
3352...

result:

ok q=100000

Test #133:

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

input:

9970 100000
3 1
1 5
1 9
1 13
17 1
21 1
25 1
1 29
33 1
1 37
1 41
45 1
49 1
53 1
57 1
61 1
65 1
1 69
1 73
1 77
1 81
85 1
1 89
93 1
97 1
101 1
105 1
1 109
113 1
117 1
121 1
125 1
1 129
133 1
1 137
1 141
1 145
149 1
1 153
157 1
1 161
1 165
1 169
1 173
1 177
181 1
185 1
189 1
193 1
1 197
201 1
1 205
209 ...

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 q=100000

Test #134:

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

input:

9970 100000
1 2
1 3
1 5
9 1
1 13
1 17
1 21
1 25
29 1
1 33
37 1
1 41
45 1
1 49
1 53
1 57
1 61
65 1
69 1
73 1
1 77
1 81
1 85
1 89
1 93
1 97
101 1
105 1
109 1
1 113
1 117
121 1
125 1
1 129
1 133
137 1
1 141
145 1
1 149
153 1
1 157
1 161
1 165
169 1
173 1
1 177
1 181
1 185
1 189
193 1
1 197
1 201
205 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
2
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
...

result:

ok q=100000

Test #135:

score: 0
Accepted
time: 15ms
memory: 58532kb

input:

9970 100000
1 2
1 5
9 1
13 1
17 1
1 21
25 1
1 29
33 1
1 37
41 1
1 45
1 49
1 53
1 57
61 1
65 1
69 1
73 1
77 1
1 81
85 1
89 1
93 1
1 97
101 1
1 105
1 109
1 113
1 117
1 121
1 125
129 1
1 133
1 137
1 141
1 145
1 149
153 1
1 157
1 161
165 1
169 1
1 173
177 1
181 1
1 185
189 1
193 1
197 1
1 201
205 1
1 20...

output:

2494
1
2495
2
3
4
5
6
7
8
2496
2497
2498
2499
9
10
11
12
7479
4988
4989
0
4990
2500
13
14
15
2501
2502
2503
4991
4992
7480
2504
7481
16
7482
0
4993
4994
4995
4996
2505
2506
2507
17
2508
4997
4998
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
4999
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
3...

result:

ok q=100000

Test #136:

score: 0
Accepted
time: 15ms
memory: 56572kb

input:

9970 100000
1 3
5 1
9 1
13 1
1 17
21 1
25 1
1 29
33 1
1 37
1 41
1 45
1 49
53 1
57 1
61 1
65 1
69 1
73 1
77 1
1 81
85 1
1 89
1 93
1 97
1 101
105 1
109 1
113 1
1 117
1 121
1 125
129 1
1 133
137 1
141 1
145 1
1 149
153 1
157 1
1 161
1 165
1 169
1 173
1 177
181 1
1 185
1 189
193 1
1 197
1 201
1 205
1 20...

output:

0
0
0
0
4987
7479
2494
1
4988
4989
7480
2495
2496
2497
2
3
4
5
6
7
8
7481
4990
4991
4992
7482
7483
4993
4994
7484
4995
4996
7485
7486
9
7487
4997
10
11
12
2498
2499
2500
13
14
15
16
17
18
19
0
0
4998
4999
5000
5001
5002
0
0
0
20
21
22
23
24
25
26
27
28
29
30
31
32
5003
5004
5005
33
34
35
36
37
38
39...

result:

ok q=100000

Test #137:

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

input:

9970 100000
3 1
4 1
1 5
6 1
11 1
1 16
1 21
1 26
1 31
36 1
41 1
1 46
1 51
1 56
61 1
66 1
1 71
76 1
81 1
86 1
91 1
1 96
101 1
106 1
111 1
1 116
1 121
1 126
131 1
136 1
1 141
146 1
151 1
156 1
1 161
1 166
171 1
176 1
181 1
186 1
1 191
196 1
201 1
206 1
211 1
216 1
221 1
226 1
231 1
1 236
1 241
1 246
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 q=100000

Test #138:

score: 0
Accepted
time: 23ms
memory: 56688kb

input:

9970 100000
3 1
6 1
11 1
1 16
1 21
26 1
1 31
1 36
1 41
46 1
51 1
56 1
61 1
1 66
1 71
1 76
81 1
86 1
1 91
96 1
1 101
1 106
1 111
116 1
1 121
126 1
131 1
1 136
141 1
1 146
151 1
156 1
161 1
166 1
1 171
176 1
1 181
186 1
1 191
196 1
1 201
206 1
1 211
1 216
1 221
1 226
1 231
1 236
241 1
1 246
251 1
1 25...

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 q=100000

Test #139:

score: 0
Accepted
time: 15ms
memory: 58388kb

input:

9970 100000
1 2
1 6
11 1
16 1
1 21
26 1
31 1
1 36
41 1
46 1
51 1
56 1
1 61
66 1
1 71
1 76
81 1
1 86
91 1
1 96
1 101
106 1
111 1
116 1
121 1
126 1
1 131
1 136
141 1
1 146
151 1
156 1
161 1
166 1
171 1
176 1
181 1
186 1
191 1
1 196
1 201
206 1
1 211
1 216
1 221
1 226
1 231
1 236
241 1
246 1
1 251
256 ...

output:

3990
0
5984
1996
7978
1995
3991
3992
1
3993
2
3
4
5
6
3994
3995
7
8
9
10
11
1997
1998
1999
2000
3996
3997
12
13
14
3998
5985
0
15
0
7979
2001
16
17
18
19
20
21
5986
0
22
0
2002
2003
2004
23
24
25
26
3999
4000
2005
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
2006
200...

result:

ok q=100000

Test #140:

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

input:

9970 100000
1 2
3 1
6 1
1 11
1 16
1 21
1 26
31 1
36 1
41 1
1 46
51 1
56 1
1 61
1 66
71 1
1 76
81 1
86 1
91 1
96 1
1 101
106 1
111 1
116 1
121 1
126 1
131 1
136 1
1 141
1 146
151 1
1 156
1 161
1 166
1 171
1 176
1 181
1 186
191 1
1 196
201 1
206 1
1 211
216 1
221 1
226 1
231 1
1 236
1 241
1 246
251 1
...

output:

0
5984
5985
5986
5987
5988
5989
1996
5990
5991
5992
5993
1
1997
3990
1998
1999
2000
2001
2002
2003
5994
5995
5996
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
39...

result:

ok q=100000

Test #141:

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

input:

9970 100000
2 1
1 6
1 7
13 1
19 1
1 25
1 31
1 37
1 43
1 49
1 55
1 61
1 67
73 1
79 1
1 85
91 1
1 97
103 1
109 1
115 1
121 1
127 1
1 133
1 139
145 1
151 1
157 1
1 163
1 169
175 1
181 1
187 1
1 193
199 1
1 205
1 211
1 217
223 1
1 229
1 235
241 1
247 1
253 1
1 259
1 265
271 1
277 1
1 283
289 1
1 295
301...

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
4991
3327
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 q=100000

Test #142:

score: 0
Accepted
time: 34ms
memory: 56532kb

input:

9970 100000
2 1
1 3
4 1
1 6
7 1
1 13
1 19
1 25
1 31
1 37
43 1
1 49
1 55
61 1
67 1
1 73
79 1
85 1
1 91
1 97
1 103
109 1
115 1
121 1
1 127
133 1
1 139
145 1
1 151
157 1
163 1
1 169
175 1
181 1
187 1
193 1
1 199
205 1
1 211
217 1
223 1
229 1
1 235
241 1
1 247
1 253
259 1
265 1
271 1
1 277
1 283
289 1
2...

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 q=100000

Test #143:

score: 0
Accepted
time: 23ms
memory: 58280kb

input:

9970 100000
4 1
1 5
6 1
7 1
1 13
1 19
25 1
31 1
37 1
1 43
49 1
55 1
61 1
67 1
1 73
1 79
85 1
1 91
97 1
103 1
1 109
1 115
121 1
1 127
133 1
1 139
1 145
151 1
1 157
163 1
1 169
175 1
181 1
187 1
1 193
1 199
1 205
211 1
1 217
1 223
229 1
235 1
1 241
247 1
253 1
1 259
265 1
1 271
1 277
1 283
1 289
1 295...

output:

6652
0
1667
3
1666
2
4990
4
1
1668
1669
1665
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
4991
3329
3330
3331
4992
3332
4993
3333
3334
4994
25
26
8313
3335
27
28
29
30
31
1670
3336
32
33
3337
3338
4995
3339
4996
4997
1671
1672
1673
34
35
36
37
38
39
40
41
42
4998
1674
1675
1676
1677
1678
1...

result:

ok q=100000

Test #144:

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

input:

9970 100000
3 1
1 4
5 1
1 7
13 1
19 1
1 25
1 31
37 1
43 1
1 49
55 1
61 1
67 1
73 1
79 1
1 85
1 91
1 97
1 103
109 1
1 115
1 121
1 127
1 133
139 1
1 145
151 1
1 157
163 1
1 169
175 1
181 1
187 1
1 193
199 1
205 1
211 1
217 1
1 223
1 229
235 1
1 241
1 247
1 253
259 1
1 265
271 1
1 277
283 1
1 289
295 1...

output:

3
1665
2
6652
4990
3327
1
4
5
6
7
8
9
3328
10
11
12
13
14
15
3329
3330
16
17
18
19
20
21
22
23
24
25
26
27
28
29
4991
4992
4993
8313
6653
1666
6654
6655
6656
4994
4995
4996
4997
3331
3332
3333
3334
3335
3336
3337
3338
3339
30
3340
3341
3342
3343
3344
3345
3346
3347
3348
4998
8314
8315
8316
6657
6658...

result:

ok q=100000

Test #145:

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

input:

9970 100000
3 1
6 1
1 7
1 8
15 1
1 22
29 1
1 36
43 1
1 50
1 57
1 64
71 1
1 78
1 85
92 1
1 99
1 106
1 113
1 120
1 127
1 134
141 1
148 1
1 155
162 1
169 1
176 1
183 1
190 1
197 1
204 1
211 1
1 218
225 1
1 232
239 1
246 1
1 253
1 260
1 267
1 274
281 1
1 288
1 295
302 1
309 1
1 316
1 323
330 1
1 337
344...

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 q=100000

Test #146:

score: 0
Accepted
time: 34ms
memory: 56588kb

input:

9970 100000
1 3
5 1
6 1
1 8
15 1
22 1
29 1
36 1
1 43
50 1
57 1
64 1
1 71
1 78
1 85
92 1
99 1
106 1
113 1
1 120
127 1
134 1
141 1
1 148
1 155
1 162
169 1
1 176
1 183
1 190
197 1
1 204
1 211
218 1
1 225
1 232
1 239
1 246
253 1
1 260
1 267
274 1
1 281
288 1
1 295
302 1
1 309
1 316
1 323
1 330
1 337
344...

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
7128
2856
1430
0
0
0
0
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 q=100000

Test #147:

score: 0
Accepted
time: 23ms
memory: 58516kb

input:

9970 100000
3 1
4 1
6 1
8 1
1 15
1 22
1 29
36 1
43 1
50 1
1 57
64 1
1 71
78 1
1 85
1 92
99 1
106 1
113 1
120 1
127 1
134 1
1 141
1 148
155 1
162 1
1 169
1 176
183 1
1 190
197 1
1 204
1 211
218 1
1 225
232 1
1 239
1 246
1 253
260 1
267 1
1 274
1 281
288 1
1 295
1 302
1 309
1 316
323 1
1 330
1 337
1 3...

output:

1430
3
5704
7128
1429
1428
1
2
5703
4279
2855
2856
4
5
6
7
8
4280
4281
1431
1432
1433
1434
2857
2858
2859
9
10
11
0
12
13
7129
1435
14
15
16
2860
17
18
19
20
21
22
23
24
25
26
27
1436
1437
1438
1439
1440
4282
5705
2861
28
29
5706
4283
4284
7130
1441
1442
30
31
32
33
34
2862
2863
5707
7131
7132
0
428...

result:

ok q=100000

Test #148:

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

input:

9970 100000
3 1
5 1
1 8
15 1
1 22
1 29
36 1
43 1
50 1
57 1
64 1
1 71
1 78
85 1
1 92
1 99
106 1
1 113
120 1
127 1
1 134
141 1
1 148
155 1
1 162
169 1
176 1
1 183
190 1
197 1
1 204
211 1
218 1
225 1
1 232
239 1
1 246
253 1
260 1
1 267
274 1
1 281
288 1
295 1
1 302
1 309
316 1
323 1
330 1
337 1
344 1
3...

output:

0
0
5705
2854
1429
1428
1
4281
2
2855
4280
3
1427
4
5
6
7
8
9
10
1430
1431
1432
1433
1434
8552
8553
8554
1435
1436
1437
1438
1439
4279
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
5706
1460
1461
...

result:

ok q=100000

Test #149:

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

input:

9970 100000
2 1
1 3
1 4
5 1
7 1
8 1
1 9
1 17
25 1
1 33
1 41
1 49
1 57
1 65
73 1
1 81
1 89
1 97
1 105
1 113
121 1
1 129
137 1
145 1
1 153
161 1
169 1
177 1
1 185
193 1
201 1
209 1
1 217
1 225
233 1
241 1
1 249
257 1
265 1
1 273
1 281
289 1
297 1
305 1
1 313
321 1
329 1
1 337
345 1
353 1
1 361
1 369
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 q=100000

Test #150:

score: 0
Accepted
time: 36ms
memory: 56616kb

input:

9970 100000
1 4
1 5
6 1
8 1
9 1
17 1
25 1
1 33
1 41
1 49
57 1
65 1
1 73
81 1
89 1
97 1
105 1
1 113
121 1
1 129
137 1
145 1
1 153
1 161
1 169
177 1
1 185
1 193
1 201
209 1
217 1
1 225
233 1
1 241
249 1
257 1
265 1
1 273
1 281
289 1
1 297
305 1
1 313
321 1
1 329
1 337
345 1
1 353
361 1
369 1
377 1
385...

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
7486
1254
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 q=100000

Test #151:

score: 0
Accepted
time: 23ms
memory: 56520kb

input:

9970 100000
1 3
1 6
8 1
1 9
17 1
25 1
33 1
1 41
1 49
57 1
65 1
73 1
81 1
89 1
1 97
105 1
113 1
121 1
1 129
1 137
1 145
1 153
161 1
169 1
177 1
1 185
193 1
1 201
209 1
1 217
1 225
233 1
1 241
249 1
257 1
265 1
1 273
281 1
289 1
1 297
1 305
1 313
1 321
1 329
1 337
345 1
353 1
1 361
1 369
1 377
385 1
1...

output:

2501
3748
4994
6240
1250
2
3747
2499
7486
1251
2500
1252
3
6241
3749
1253
1254
3750
3751
1255
1
4
5
6
7
8
9
10
11
12
13
14
15
1256
1257
1258
16
17
18
19
20
21
22
23
24
25
26
27
28
3752
29
30
31
32
33
34
35
36
37
1259
1260
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
1261
1262
55
56
1263
1264
1...

result:

ok q=100000

Test #152:

score: 0
Accepted
time: 23ms
memory: 56468kb

input:

9970 100000
2 1
1 3
5 1
1 9
17 1
25 1
1 33
41 1
1 49
1 57
65 1
73 1
81 1
89 1
1 97
105 1
1 113
121 1
1 129
1 137
145 1
153 1
1 161
1 169
1 177
185 1
193 1
201 1
1 209
1 217
225 1
1 233
241 1
249 1
257 1
265 1
1 273
1 281
1 289
297 1
1 305
1 313
1 321
1 329
337 1
345 1
353 1
1 361
1 369
377 1
1 385
1...

output:

0
0
3748
6241
3747
1252
6242
3
2
6243
6244
6245
6246
6247
4995
2499
4994
1250
2501
2500
6248
6249
6250
1
4
5
6
7
3746
1251
8
9
10
11
12
13
14
15
16
17
3749
4996
4997
4998
2502
2503
2504
2505
3750
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
1253
1254
1255
12...

result:

ok q=100000

Test #153:

score: 0
Accepted
time: 159ms
memory: 97024kb

input:

1000 100000
1 5
17 1
22 1
33 1
1 34
35 1
41 1
1 55
1 56
60 1
75 1
76 1
1 77
88 1
1 89
1 93
1 95
1 96
97 1
98 1
1 103
1 105
108 1
1 112
1 115
116 1
143 1
1 147
156 1
164 1
1 168
183 1
188 1
197 1
198 1
199 1
210 1
1 213
215 1
1 217
223 1
224 1
225 1
228 1
1 233
236 1
240 1
249 1
250 1
258 1
259 1
1 2...

output:

33778

result:

ok q=100000

Test #154:

score: 0
Accepted
time: 126ms
memory: 66120kb

input:

1000 100000
1 10
1 16
21 1
23 1
1 28
30 1
1 31
1 36
39 1
1 44
1 45
1 48
1 57
61 1
62 1
1 63
67 1
69 1
77 1
1 78
1 84
1 91
94 1
96 1
1 100
1 104
112 1
115 1
1 120
1 124
128 1
130 1
137 1
148 1
1 161
164 1
170 1
1 173
1 185
188 1
189 1
1 192
1 195
1 200
207 1
1 210
1 219
230 1
237 1
239 1
245 1
247 1
...

output:

31824
90641
12405
64410
8572
85054
20936
54597
58376
99047
98820
65830
78011
78010
12587
95885
86651
76365
81970
6620
55377
55376
24894
87868
5644
5643
98843
64066
64063
57204
93538
99911
99910
88016
48906
19883
97727
98268
98267
95847
24699
98288
88106
75672
75671
75670
75669
55495
98452
91059
3719...

result:

ok q=100000

Test #155:

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

input:

1000 100000
1 10
1 13
14 1
16 1
1 19
21 1
32 1
1 39
40 1
1 44
49 1
1 51
52 1
1 54
1 56
61 1
63 1
70 1
1 73
1 83
1 87
1 99
101 1
104 1
111 1
114 1
119 1
121 1
122 1
126 1
1 130
133 1
135 1
1 146
150 1
158 1
170 1
183 1
1 184
185 1
186 1
187 1
1 190
192 1
196 1
205 1
208 1
223 1
227 1
1 235
1 242
244 ...

output:

94802
54884
53953
53952
70220
86919
86918
83045
12224
40187
40186
84761
99586
25252
25251
31087
96650
75092
91300
19108
19107
46524
46523
8352
95057
41893
91164
20860
20859
76249
99031
99030
100000
15868
15866
74131
7204
58056
81223
81222
99830
99829
97335
32787
32786
25233
72109
87478
33796
33795
3...

result:

ok q=100000

Test #156:

score: 0
Accepted
time: 74ms
memory: 51632kb

input:

1000 100000
1 2
3 1
5 1
1 8
9 1
10 1
1 11
19 1
21 1
42 1
44 1
45 1
1 46
1 67
69 1
1 75
1 87
1 88
100 1
103 1
114 1
121 1
1 123
127 1
131 1
1 143
1 149
151 1
153 1
159 1
1 163
1 174
176 1
1 185
1 186
191 1
1 194
1 205
210 1
1 215
1 217
1 219
1 220
222 1
1 229
232 1
234 1
1 237
240 1
1 241
245 1
1 247...

output:

0
0
0
0
0
0
0
98307
98483
19499
19498
30170
30169
32158
10245
10244
10243
98838
18629
18628
99423
95831
95830
79898
79897
79896
79895
98054
98053
74281
92985
92984
92983
92982
47805
31527
85929
42105
42104
99089
76961
80930
80929
33601
33600
33599
51451
51450
51449
39619
39618
39617
16999
98837
9587...

result:

ok q=100000

Test #157:

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

input:

1000 100000
1 6
1 12
18 1
19 1
34 1
1 37
41 1
53 1
58 1
1 63
1 66
1 70
73 1
1 80
1 82
94 1
1 104
1 110
1 112
1 114
1 115
118 1
121 1
126 1
131 1
136 1
1 137
139 1
1 145
146 1
148 1
1 149
1 159
1 161
164 1
170 1
186 1
189 1
191 1
193 1
1 197
1 206
207 1
208 1
212 1
224 1
1 225
1 226
228 1
229 1
233 1...

output:

71041
71040
61456
61455
61454
61453
31721
78498
78497
78496
89600
99665
99664
67715
67714
67713
67712
67711
67710
67709
99906
30022
30021
99790
99789
99787
54156
54155
54154
99999
99982
43566
43565
43564
99009
99008
89574
61435
96547
95884
94632
15524
97523
97522
91309
91308
91307
91306
91305
91304
...

result:

ok q=100000

Test #158:

score: 0
Accepted
time: 33ms
memory: 36840kb

input:

1000 100000
1 10
1 20
23 1
26 1
32 1
35 1
1 41
47 1
1 52
1 54
57 1
1 58
61 1
68 1
71 1
1 82
1 85
90 1
103 1
1 114
1 124
125 1
129 1
1 133
1 135
139 1
140 1
1 143
1 158
1 160
1 161
164 1
1 169
174 1
181 1
186 1
187 1
188 1
189 1
199 1
1 208
1 227
1 228
1 232
1 240
1 243
250 1
1 255
260 1
270 1
272 1
...

output:

0
0
93530
93529
93528
93527
93526
93525
96123
74698
74697
74696
74695
74694
74693
74692
74691
71872
71871
71870
71869
71868
71867
58609
58608
58607
58606
58605
58604
58603
58602
95498
95497
95496
95495
95494
95493
14368
14367
14366
14365
14364
14363
14362
98452
52011
52010
52009
52008
52007
52006
91...

result:

ok q=100000

Test #159:

score: 0
Accepted
time: 20ms
memory: 33220kb

input:

1000 100000
5 1
1 11
1 20
1 37
43 1
44 1
47 1
48 1
54 1
1 63
69 1
1 70
72 1
73 1
83 1
84 1
1 86
1 93
1 94
1 95
1 101
1 108
114 1
115 1
124 1
137 1
1 141
1 144
1 151
158 1
159 1
160 1
167 1
175 1
181 1
1 183
1 191
1 196
1 198
1 203
1 213
1 215
216 1
239 1
245 1
246 1
249 1
1 254
261 1
264 1
277 1
289...

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 q=100000

Test #160:

score: 0
Accepted
time: 152ms
memory: 97340kb

input:

1000 100000
2 1
15 1
1 18
21 1
1 23
33 1
52 1
54 1
55 1
1 56
1 57
1 61
62 1
1 66
69 1
1 72
1 73
1 75
79 1
1 85
87 1
1 88
1 89
95 1
104 1
121 1
1 123
1 127
1 131
1 135
1 136
137 1
1 139
1 148
150 1
1 156
1 162
1 189
192 1
193 1
1 194
1 197
1 209
1 213
1 216
1 218
220 1
221 1
222 1
1 230
248 1
1 249
1...

output:

58543

result:

ok q=100000

Test #161:

score: 0
Accepted
time: 128ms
memory: 65204kb

input:

1000 100000
5 1
11 1
1 15
23 1
25 1
1 26
1 27
1 30
35 1
39 1
1 49
1 53
1 57
1 72
1 73
1 78
1 81
83 1
1 85
1 87
88 1
96 1
101 1
1 107
110 1
1 112
116 1
118 1
1 121
1 123
124 1
125 1
131 1
134 1
1 137
1 140
141 1
143 1
155 1
1 157
1 168
171 1
177 1
182 1
184 1
185 1
1 187
193 1
1 206
207 1
1 208
209 1...

output:

82823
82822
82001
70557
52653
99794
87589
78212
85941
50767
68846
72237
29577
65668
92370
54363
77912
91117
99977
94791
88688
59779
90642
98588
50634
99283
59021
99981
75806
48391
92962
66907
92547
92546
60273
60272
90998
47954
96601
99643
89894
96076
4105
4103
64457
92225
66464
67924
67923
35575
49...

result:

ok q=100000

Test #162:

score: 0
Accepted
time: 94ms
memory: 66176kb

input:

1000 100000
1 6
7 1
1 12
1 22
1 25
1 29
1 31
36 1
45 1
1 67
75 1
1 81
85 1
1 89
95 1
97 1
1 103
115 1
123 1
125 1
1 129
133 1
137 1
148 1
1 155
158 1
178 1
179 1
1 181
1 187
1 188
205 1
207 1
208 1
1 211
1 214
1 219
1 223
231 1
1 237
239 1
1 242
243 1
251 1
256 1
1 260
262 1
269 1
270 1
271 1
275 1
...

output:

33011
33010
43005
27767
78793
7291
7290
7285
49609
49607
49606
76482
98989
98988
98987
80597
21883
21879
35136
35135
65138
67699
67694
90460
607
96302
51668
51666
56605
94597
80850
96350
96346
96345
98538
77433
77432
36276
99935
99867
81321
86149
86148
86147
93044
87901
87900
87902
75028
93556
64884...

result:

ok q=100000

Test #163:

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

input:

1000 100000
3 1
8 1
9 1
1 16
28 1
45 1
1 49
1 55
1 56
57 1
66 1
68 1
1 70
1 74
78 1
1 84
1 85
86 1
87 1
97 1
99 1
103 1
105 1
1 107
1 111
1 112
1 127
130 1
1 133
1 134
142 1
143 1
149 1
161 1
167 1
1 168
172 1
1 174
1 179
1 190
193 1
1 195
1 202
205 1
1 209
216 1
217 1
218 1
1 219
1 229
1 234
236 1
...

output:

64088
64087
21336
82843
86524
86521
86519
93486
20787
68200
68197
68191
74241
74240
74238
98589
72127
72126
99424
39702
39699
39697
91724
99008
23745
52152
94805
95440
95439
87065
87064
87063
98988
98987
98986
47473
94548
94547
98781
98778
83842
43496
69779
80894
80893
80891
80886
80884
80880
98540
...

result:

ok q=100000

Test #164:

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

input:

1000 100000
1 13
16 1
17 1
1 22
1 24
29 1
1 30
1 55
57 1
1 58
59 1
1 72
73 1
75 1
77 1
1 85
87 1
1 89
90 1
1 93
1 99
101 1
1 103
1 106
1 119
1 122
125 1
145 1
1 151
1 158
1 163
1 167
170 1
179 1
184 1
1 187
1 193
1 201
202 1
204 1
1 207
1 211
213 1
216 1
222 1
224 1
226 1
234 1
1 242
246 1
259 1
1 2...

output:

91585
99590
99589
99588
99529
99402
99275
67719
83492
88398
97882
97881
97880
97879
97878
97874
66820
74095
74094
74092
74091
99483
99482
99481
54045
74711
74707
74706
74705
95745
95744
95742
95739
95735
95732
95730
95729
95728
85196
85194
85193
85191
2381
2377
2374
90920
90917
90913
90912
90911
909...

result:

ok q=100000

Test #165:

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

input:

1000 100000
2 1
3 1
9 1
11 1
22 1
1 33
1 39
1 42
1 43
1 44
1 49
67 1
68 1
73 1
76 1
78 1
81 1
1 84
85 1
87 1
88 1
1 93
1 99
108 1
128 1
1 129
1 132
134 1
135 1
138 1
1 142
144 1
1 150
1 155
158 1
160 1
1 170
1 175
183 1
1 193
1 197
213 1
1 215
216 1
222 1
1 225
1 233
234 1
235 1
242 1
258 1
268 1
1 ...

output:

17061
17059
11386
11380
11378
11377
11376
11374
11372
11369
11366
11364
11359
11358
11357
96669
96668
96659
96658
96656
96651
96649
51447
51445
51440
51439
51438
98510
93435
93434
82782
96736
96735
96732
96729
18145
18143
18142
18140
18139
68237
68235
68233
66891
66889
66888
66887
66886
66884
66882
...

result:

ok q=100000

Test #166:

score: 0
Accepted
time: 13ms
memory: 32196kb

input:

1000 100000
13 1
22 1
1 24
1 29
32 1
42 1
46 1
50 1
1 56
1 62
66 1
1 68
1 69
71 1
1 73
1 75
81 1
1 87
88 1
94 1
1 96
101 1
107 1
1 108
110 1
111 1
126 1
1 143
148 1
1 150
160 1
166 1
176 1
1 180
1 183
1 195
1 206
211 1
1 213
1 216
219 1
236 1
1 238
1 242
1 249
251 1
252 1
256 1
266 1
1 277
1 293
295...

output:

88019
88018
88007
88004
87998
87997
87996
87994
87988
87987
87986
87984
87983
87982
87980
87979
87977
87976
87974
87971
87966
87963
87962
87960
87958
87957
87953
87951
87947
87945
87944
87520
86819
85235
84921
84463
83827
82898
82238
80607
80321
79952
75911
73670
73053
71984
70745
67708
67360
65866
...

result:

ok q=100000

Test #167:

score: 0
Accepted
time: 149ms
memory: 99768kb

input:

1000 100000
1 4
1 7
8 1
14 1
16 1
1 17
20 1
22 1
1 28
1 29
34 1
1 35
1 38
1 41
1 49
1 53
1 57
1 58
1 74
1 84
85 1
1 90
95 1
103 1
104 1
1 107
108 1
110 1
1 117
1 118
1 126
1 141
142 1
1 145
1 147
1 152
153 1
154 1
1 163
1 165
166 1
173 1
175 1
180 1
1 184
188 1
1 189
194 1
201 1
204 1
207 1
1 210
21...

output:

27330

result:

ok q=100000

Test #168:

score: 0
Accepted
time: 122ms
memory: 65392kb

input:

1000 100000
15 1
18 1
1 26
31 1
1 37
1 40
42 1
1 46
1 48
1 49
1 53
55 1
1 68
75 1
82 1
83 1
89 1
92 1
102 1
106 1
1 113
1 114
1 119
1 121
1 123
128 1
129 1
130 1
1 133
140 1
1 143
1 153
1 154
1 163
1 167
168 1
171 1
176 1
178 1
1 190
191 1
1 192
1 200
201 1
204 1
205 1
1 206
212 1
1 215
1 218
1 223
...

output:

97004
55217
96690
98749
97041
89426
88064
80935
37322
37321
64414
74604
74603
90528
54119
34596
834
833
82518
60339
96724
61564
63588
75185
75184
91348
98799
99781
98728
98177
98176
80032
93123
87471
15819
47381
96798
85478
5010
53014
96723
95686
82847
74135
86710
98364
97177
97176
69461
30147
97333...

result:

ok q=100000

Test #169:

score: 0
Accepted
time: 109ms
memory: 64460kb

input:

1000 100000
5 1
14 1
1 17
33 1
40 1
55 1
1 58
59 1
1 61
1 66
70 1
1 71
1 75
76 1
79 1
1 81
90 1
95 1
1 102
1 104
1 109
119 1
130 1
1 131
142 1
144 1
147 1
1 154
158 1
1 161
170 1
178 1
1 182
187 1
189 1
1 211
217 1
1 229
1 233
245 1
248 1
1 249
254 1
256 1
1 257
258 1
271 1
1 273
1 277
286 1
1 287
1...

output:

0
0
10060
56079
17066
17065
66388
57535
68030
84284
99975
99974
99354
90641
81237
98931
99904
86535
86534
98319
99115
99999
56621
66516
66515
99998
99980
98047
86509
57415
98491
98490
98489
43674
91340
77245
77244
77243
71660
92792
39617
99097
98484
34071
34070
78902
47143
47142
47141
96920
99227
44...

result:

ok q=100000

Test #170:

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

input:

1000 100000
1 5
1 13
1 19
26 1
1 29
34 1
35 1
38 1
39 1
45 1
1 46
1 67
79 1
1 92
94 1
1 97
108 1
1 111
1 120
122 1
1 129
131 1
140 1
1 143
148 1
159 1
1 169
175 1
180 1
185 1
187 1
1 189
1 192
1 195
200 1
205 1
1 208
1 213
1 228
1 232
243 1
244 1
1 245
1 246
1 263
271 1
274 1
1 281
292 1
299 1
301 1...

output:

0
78216
78215
30020
6349
84027
91005
91004
29855
29854
29853
66193
78130
66123
99898
92118
87583
94786
94785
94784
99277
49419
82930
96836
99980
84959
84958
84581
39746
39745
91950
91949
91948
66968
66967
66966
83352
91899
84902
83457
82124
78153
77296
85552
85551
85550
32361
63882
93183
75654
75653...

result:

ok q=100000

Test #171:

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

input:

1000 100000
1 3
4 1
1 5
8 1
1 11
1 21
1 24
1 27
36 1
45 1
1 51
1 74
1 75
79 1
1 80
83 1
1 86
1 93
1 95
98 1
101 1
106 1
109 1
110 1
117 1
127 1
1 130
1 131
1 137
1 141
145 1
1 154
155 1
160 1
1 164
166 1
168 1
169 1
172 1
1 173
174 1
181 1
1 185
1 188
198 1
1 202
1 212
217 1
1 228
230 1
1 234
1 235
...

output:

0
0
44449
44448
99905
28873
28872
95677
27341
27340
27339
27338
27337
27336
9679
9678
86078
79821
79820
79819
17551
17550
39033
39032
39031
39030
39029
39028
44889
76649
76648
76647
57702
57701
57700
57699
57698
94602
85364
85363
85362
85361
85360
81663
69622
43827
43826
43825
43824
43823
43822
2476...

result:

ok q=100000

Test #172:

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

input:

1000 100000
4 1
1 6
8 1
1 9
12 1
16 1
1 20
1 32
50 1
1 62
70 1
1 72
1 74
1 77
78 1
1 79
1 84
88 1
89 1
94 1
95 1
1 97
107 1
114 1
1 115
126 1
130 1
132 1
1 138
1 144
1 156
1 162
1 163
165 1
178 1
1 181
1 185
1 192
200 1
214 1
1 215
1 218
1 221
1 226
1 232
1 235
1 237
246 1
1 249
1 256
1 269
279 1
28...

output:

0
0
0
0
0
97491
99467
99466
99465
67701
67700
67699
67698
67697
67695
67694
67693
67692
67691
67690
81797
81796
81795
66656
66655
66654
10755
10754
10753
10752
10751
10750
99967
99966
99965
99964
99963
99945
99919
95298
95297
95296
95295
95294
95293
95292
95291
81640
81639
81638
81637
80853
80852
80...

result:

ok q=100000

Test #173:

score: 0
Accepted
time: 13ms
memory: 34148kb

input:

1000 100000
4 1
7 1
10 1
1 11
1 15
19 1
20 1
25 1
1 37
40 1
41 1
1 45
1 49
1 55
62 1
67 1
68 1
1 70
1 84
1 87
98 1
102 1
1 122
1 131
141 1
1 148
149 1
1 150
1 155
1 165
1 171
1 179
183 1
185 1
1 189
191 1
1 193
201 1
1 205
217 1
218 1
219 1
1 237
1 240
1 251
257 1
261 1
268 1
274 1
1 285
286 1
1 289...

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 q=100000

Test #174:

score: 0
Accepted
time: 44ms
memory: 34572kb

input:

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

Test #175:

score: 0
Accepted
time: 50ms
memory: 36092kb

input:

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

Test #176:

score: 0
Accepted
time: 18ms
memory: 37448kb

input:

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

output:

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

result:

ok q=100000

Test #177:

score: 0
Accepted
time: 18ms
memory: 33280kb

input:

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

output:

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

result:

ok q=100000

Test #178:

score: 0
Accepted
time: 34ms
memory: 33680kb

input:

970 100000
2 1
3 1
1 5
1 7
1 9
11 1
1 13
15 1
1 17
19 1
1 21
23 1
1 25
1 27
29 1
31 1
1 33
35 1
37 1
39 1
1 41
1 43
1 45
1 47
1 49
51 1
1 53
55 1
1 57
59 1
61 1
63 1
1 65
67 1
1 69
1 71
73 1
75 1
77 1
79 1
1 81
83 1
1 85
1 87
89 1
91 1
93 1
1 95
1 97
1 99
101 1
1 103
1 105
1 107
1 109
1 111
113 1
11...

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
1
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #179:

score: 0
Accepted
time: 37ms
memory: 31760kb

input:

970 100000
2 1
1 3
1 5
7 1
1 9
11 1
13 1
1 15
17 1
1 19
1 21
23 1
1 25
27 1
29 1
31 1
1 33
1 35
1 37
1 39
1 41
1 43
1 45
47 1
1 49
1 51
1 53
55 1
57 1
59 1
61 1
63 1
1 65
1 67
1 69
1 71
1 73
1 75
77 1
79 1
1 81
83 1
1 85
87 1
89 1
1 91
1 93
1 95
97 1
99 1
1 101
1 103
1 105
107 1
109 1
111 1
113 1
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 q=100000

Test #180:

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

input:

970 100000
1 2
3 1
1 5
7 1
9 1
11 1
13 1
15 1
17 1
1 19
21 1
1 23
1 25
1 27
1 29
1 31
33 1
35 1
37 1
1 39
1 41
43 1
1 45
1 47
49 1
51 1
1 53
55 1
57 1
1 59
1 61
1 63
65 1
67 1
1 69
1 71
1 73
1 75
1 77
79 1
1 81
1 83
1 85
1 87
89 1
1 91
93 1
95 1
97 1
1 99
1 101
103 1
105 1
107 1
1 109
111 1
1 113
1 ...

output:

969
0
968
0
967
0
966
485
1
0
484
965
483
964
482
0
963
481
480
962
961
479
478
960
477
959
476
0
958
0
475
0
957
474
473
956
955
0
472
954
471
953
952
470
951
0
469
950
468
0
949
467
466
948
947
0
465
946
464
945
944
463
462
0
461
0
943
460
942
0
941
0
459
0
458
940
457
939
456
938
937
0
455
936
93...

result:

ok q=100000

Test #181:

score: 0
Accepted
time: 23ms
memory: 31172kb

input:

970 100000
2 1
3 1
5 1
1 7
9 1
11 1
1 13
15 1
1 17
19 1
21 1
23 1
1 25
1 27
29 1
1 31
1 33
1 35
1 37
39 1
41 1
1 43
45 1
1 47
1 49
51 1
53 1
1 55
1 57
59 1
1 61
63 1
1 65
67 1
69 1
71 1
73 1
75 1
1 77
1 79
1 81
83 1
1 85
87 1
89 1
1 91
1 93
95 1
1 97
1 99
1 101
103 1
105 1
107 1
1 109
111 1
113 1
11...

output:

0
485
484
483
969
968
1
967
482
481
480
966
965
479
0
0
0
0
964
963
0
0
478
0
477
0
962
476
475
961
960
0
474
473
959
958
0
472
471
470
957
956
955
954
953
0
0
0
469
0
468
467
0
0
466
0
0
0
0
0
952
465
464
0
0
0
951
0
0
0
0
950
949
948
947
946
945
944
943
0
0
463
0
942
462
941
940
0
0
939
938
937
93...

result:

ok q=100000

Test #182:

score: 0
Accepted
time: 35ms
memory: 31888kb

input:

970 100000
1 3
4 1
1 10
1 13
16 1
19 1
22 1
1 25
28 1
1 31
34 1
40 1
43 1
58 1
61 1
1 64
70 1
73 1
76 1
82 1
85 1
1 91
94 1
1 100
1 103
1 109
1 112
115 1
118 1
1 127
1 130
1 133
136 1
1 139
142 1
157 1
1 160
1 163
1 166
1 178
1 184
1 187
1 190
193 1
1 196
199 1
1 205
208 1
217 1
1 220
223 1
226 1
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 q=100000

Test #183:

score: 0
Accepted
time: 47ms
memory: 33508kb

input:

970 100000
2 1
10 1
13 1
16 1
22 1
25 1
1 28
31 1
1 34
1 37
40 1
1 46
49 1
55 1
70 1
1 76
1 79
1 82
85 1
1 88
106 1
1 109
1 112
1 115
1 118
124 1
127 1
130 1
1 136
1 139
1 145
1 154
1 157
1 160
163 1
166 1
1 172
1 175
181 1
184 1
193 1
1 196
1 208
211 1
214 1
220 1
223 1
229 1
232 1
1 235
1 238
247 ...

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

result:

ok q=100000

Test #184:

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

input:

970 100000
3 1
4 1
1 7
10 1
13 1
16 1
19 1
1 22
1 25
1 28
37 1
1 40
43 1
46 1
1 49
52 1
1 55
1 58
1 64
1 67
1 70
73 1
76 1
79 1
1 85
91 1
94 1
97 1
106 1
1 109
1 112
115 1
1 118
1 124
127 1
133 1
139 1
1 142
1 148
1 154
157 1
160 1
1 163
166 1
169 1
172 1
175 1
181 1
1 184
187 1
1 190
1 193
199 1
1 ...

output:

619
0
410
0
409
0
618
209
1
0
208
408
617
210
407
207
406
616
206
615
614
0
205
405
204
404
203
403
613
612
202
402
201
0
200
0
199
611
198
0
197
401
196
610
609
0
400
0
399
0
398
195
608
194
193
397
396
192
395
191
190
0
394
607
189
188
606
605
604
187
186
393
185
0
184
603
392
391
390
0
183
389
60...

result:

ok q=100000

Test #185:

score: 0
Accepted
time: 21ms
memory: 33020kb

input:

970 100000
1 2
1 4
1 7
10 1
1 13
16 1
1 19
1 22
1 25
28 1
1 37
49 1
1 52
1 55
1 67
1 70
1 73
79 1
85 1
1 88
1 91
1 94
1 97
1 100
103 1
1 106
112 1
118 1
124 1
1 133
1 136
139 1
142 1
145 1
1 154
160 1
1 163
1 172
1 175
178 1
181 1
184 1
193 1
1 196
199 1
1 205
208 1
211 1
1 220
223 1
232 1
1 235
238...

output:

412
411
410
409
408
407
406
210
209
208
207
611
610
211
609
608
0
0
0
206
607
606
605
604
405
404
403
0
0
205
204
402
1
401
603
602
601
600
599
598
597
400
596
595
594
0
399
593
592
591
590
589
588
203
398
397
396
395
394
393
587
392
391
0
202
390
201
200
199
389
586
585
198
197
196
584
583
582
581
...

result:

ok q=100000

Test #186:

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

input:

970 100000
3 1
5 1
1 9
13 1
17 1
21 1
29 1
1 33
1 37
1 41
1 49
53 1
57 1
69 1
1 73
1 77
1 81
85 1
1 89
93 1
97 1
1 101
1 105
1 117
121 1
125 1
1 129
133 1
137 1
141 1
1 145
1 149
153 1
157 1
1 161
169 1
1 173
1 181
185 1
189 1
193 1
1 197
201 1
209 1
213 1
217 1
1 221
225 1
229 1
1 233
241 1
1 245
2...

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 q=100000

Test #187:

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

input:

970 100000
1 3
1 4
5 1
9 1
13 1
17 1
1 21
25 1
29 1
33 1
1 37
1 49
1 53
1 57
61 1
65 1
69 1
1 73
81 1
1 85
89 1
1 105
1 113
1 117
1 121
1 125
129 1
133 1
1 137
141 1
1 145
149 1
153 1
1 157
1 161
1 165
1 189
1 193
197 1
201 1
1 205
209 1
1 213
1 217
221 1
225 1
229 1
237 1
1 241
1 245
1 249
1 253
26...

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
210
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 q=100000

Test #188:

score: 0
Accepted
time: 23ms
memory: 33280kb

input:

970 100000
2 1
1 3
4 1
1 5
1 9
1 13
17 1
1 21
1 25
33 1
1 37
41 1
1 45
49 1
57 1
61 1
1 65
69 1
1 73
81 1
1 85
1 89
1 97
1 101
105 1
1 113
1 117
1 121
125 1
1 129
133 1
137 1
1 141
149 1
153 1
1 157
1 161
1 165
169 1
1 173
1 177
1 181
185 1
189 1
197 1
1 201
205 1
1 209
1 213
217 1
1 221
1 229
233 1...

output:

211
0
835
0
210
626
420
834
3
2
625
0
624
833
832
419
831
209
623
622
208
0
830
207
418
1
206
621
620
205
619
204
618
417
416
617
616
829
415
828
203
827
414
413
202
615
614
826
613
612
611
412
610
201
411
825
824
823
200
0
199
410
409
0
408
609
822
821
820
407
608
607
819
818
606
198
817
406
816
19...

result:

ok q=100000

Test #189:

score: 0
Accepted
time: 21ms
memory: 32920kb

input:

970 100000
2 1
1 3
4 1
1 5
1 9
13 1
1 17
1 21
1 33
1 37
1 41
45 1
49 1
53 1
57 1
1 61
1 65
1 69
73 1
1 77
1 81
85 1
1 89
1 93
97 1
1 101
105 1
1 109
1 117
1 121
125 1
1 129
137 1
1 141
145 1
1 149
1 153
161 1
1 169
1 173
1 177
181 1
1 185
1 189
1 193
197 1
1 201
205 1
1 209
213 1
217 1
1 229
233 1
2...

output:

832
209
208
207
626
3
831
830
206
205
204
203
423
422
625
829
828
1
2
202
201
200
199
624
623
622
198
197
196
195
194
621
827
826
825
620
619
824
823
618
421
420
419
418
617
822
417
416
415
414
616
615
821
614
820
613
612
819
611
413
412
411
410
409
818
817
408
816
815
814
813
812
811
407
610
609
60...

result:

ok q=100000

Test #190:

score: 0
Accepted
time: 39ms
memory: 31632kb

input:

970 93610
1 3
1 4
1 6
1 11
16 1
21 1
1 26
1 31
36 1
1 41
46 1
1 51
56 1
1 61
1 66
1 71
76 1
81 1
86 1
1 91
96 1
101 1
106 1
1 111
1 116
121 1
126 1
1 131
136 1
141 1
1 146
1 151
1 156
161 1
1 166
171 1
176 1
181 1
186 1
1 191
1 196
1 201
1 206
211 1
216 1
1 221
1 226
1 231
236 1
241 1
246 1
1 251
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 q=100000

Test #191:

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

input:

970 93610
5 1
6 1
1 11
16 1
1 21
26 1
1 31
36 1
41 1
46 1
1 51
56 1
1 61
1 66
1 71
1 76
81 1
86 1
1 91
96 1
1 101
106 1
1 111
1 116
121 1
1 126
1 131
1 136
1 141
146 1
1 151
1 156
161 1
1 166
1 171
176 1
1 181
1 186
1 191
196 1
1 201
1 206
1 211
1 216
1 221
226 1
1 231
236 1
1 241
1 246
1 251
1 256
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
584
196
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 q=100000

Test #192:

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

input:

970 93610
1 2
1 3
4 1
1 5
6 1
1 11
16 1
21 1
1 26
1 31
1 36
41 1
46 1
1 51
1 56
61 1
1 66
1 71
76 1
1 81
86 1
1 91
1 96
1 101
106 1
111 1
116 1
121 1
1 126
1 131
1 136
141 1
146 1
1 151
156 1
1 161
1 166
171 1
1 176
1 181
186 1
1 191
196 1
201 1
1 206
1 211
1 216
1 221
1 226
231 1
1 236
1 241
246 1
...

output:

584
197
2
196
777
970
391
4
3
1
195
390
583
389
194
388
193
198
969
968
192
191
190
582
776
775
189
774
967
966
581
188
387
386
187
773
772
385
384
383
771
186
185
184
382
965
964
963
183
962
381
770
580
579
769
182
181
380
768
767
961
0
379
960
378
0
180
959
958
377
578
766
577
576
765
764
376
179
...

result:

ok q=100000

Test #193:

score: 0
Accepted
time: 17ms
memory: 32936kb

input:

970 93610
1 3
1 6
1 11
1 16
21 1
26 1
1 31
36 1
41 1
46 1
51 1
1 56
61 1
66 1
1 71
1 76
81 1
1 86
91 1
96 1
1 101
106 1
1 111
116 1
1 121
1 126
1 131
1 136
141 1
146 1
151 1
156 1
1 161
166 1
1 171
1 176
1 181
1 186
1 191
1 196
201 1
1 206
1 211
216 1
221 1
226 1
231 1
1 236
1 241
1 246
1 251
1 256
...

output:

389
194
193
192
191
190
189
584
1
583
195
388
387
386
0
0
0
0
582
581
777
776
775
774
773
385
772
390
771
0
0
188
187
186
770
769
768
767
580
579
578
577
384
970
391
969
968
196
967
966
965
964
185
383
576
766
765
764
763
762
963
382
381
380
379
378
377
962
184
183
182
181
180
179
178
575
574
961
17...

result:

ok q=100000

Test #194:

score: 0
Accepted
time: 35ms
memory: 30956kb

input:

970 77288
1 2
3 1
1 4
5 1
1 7
13 1
1 19
1 25
31 1
37 1
43 1
1 49
1 55
61 1
1 67
1 73
1 79
1 85
91 1
97 1
103 1
1 109
115 1
121 1
1 127
133 1
139 1
1 145
1 151
1 157
1 163
169 1
175 1
181 1
187 1
193 1
199 1
205 1
1 211
217 1
1 223
1 229
1 235
241 1
1 247
253 1
259 1
1 265
271 1
1 277
1 283
289 1
1 2...

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
487
165
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 q=100000

Test #195:

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

input:

970 77288
1 2
5 1
1 6
7 1
13 1
19 1
1 25
31 1
37 1
43 1
49 1
55 1
61 1
1 67
1 73
1 79
1 85
91 1
1 97
103 1
109 1
115 1
1 121
127 1
1 133
139 1
145 1
151 1
157 1
1 163
1 169
175 1
1 181
1 187
1 193
199 1
1 205
1 211
1 217
223 1
1 229
235 1
1 241
1 247
253 1
1 259
1 265
1 271
1 283
289 1
295 1
301 1
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
327
326
164
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
487
2
0
0
0
0
0
0
165
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #196:

score: 0
Accepted
time: 17ms
memory: 33152kb

input:

970 77288
2 1
1 5
1 6
1 7
1 13
1 19
1 25
1 31
37 1
43 1
1 49
1 55
61 1
67 1
73 1
79 1
1 85
91 1
97 1
103 1
109 1
1 115
1 121
127 1
133 1
139 1
145 1
1 151
157 1
1 163
169 1
175 1
1 181
187 1
1 193
199 1
1 205
1 211
1 217
223 1
229 1
235 1
1 241
247 1
253 1
1 259
265 1
271 1
277 1
1 283
1 289
295 1
3...

output:

486
326
164
807
647
325
327
165
485
324
806
484
805
0
646
966
163
3
483
965
487
323
804
166
482
162
161
322
2
1
481
964
963
160
321
480
479
803
802
801
159
320
319
962
645
961
318
317
960
158
959
958
157
156
155
644
154
957
800
799
956
798
153
797
643
316
315
314
642
152
796
795
478
313
955
641
640
...

result:

ok q=100000

Test #197:

score: 0
Accepted
time: 15ms
memory: 31100kb

input:

970 77288
2 1
1 4
1 5
1 7
13 1
1 25
31 1
37 1
43 1
1 49
1 55
61 1
67 1
73 1
1 79
1 85
1 91
97 1
1 103
1 109
1 115
121 1
127 1
1 133
1 139
1 145
1 151
1 157
163 1
169 1
175 1
1 181
1 187
193 1
199 1
1 205
211 1
1 217
223 1
229 1
235 1
1 241
1 247
1 253
1 259
1 265
1 271
1 277
283 1
1 289
295 1
301 1
...

output:

160
159
319
318
1
317
316
481
158
161
961
157
156
155
154
153
152
151
480
479
478
477
476
802
801
800
799
0
0
643
642
798
797
796
795
315
314
150
482
641
640
639
3
2
313
312
475
474
473
472
471
470
149
148
147
146
960
959
958
957
956
469
468
467
466
465
464
794
311
310
309
638
637
636
635
634
483
16...

result:

ok q=100000

Test #198:

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

input:

970 66182
2 1
1 3
4 1
1 6
7 1
1 8
15 1
1 22
1 29
36 1
43 1
50 1
1 57
1 64
1 71
1 85
1 92
99 1
1 106
113 1
1 120
1 127
1 134
1 141
148 1
155 1
162 1
1 169
1 176
1 183
190 1
1 197
204 1
1 218
225 1
232 1
239 1
246 1
1 253
1 260
1 267
1 274
281 1
1 288
1 295
302 1
1 309
316 1
323 1
1 330
337 1
1 344
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
557
140
0
0
0
0
0
141
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 q=100000

Test #199:

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

input:

970 66182
1 4
5 1
1 6
7 1
8 1
15 1
1 22
29 1
36 1
43 1
1 50
1 57
1 64
71 1
1 78
1 85
92 1
1 99
1 106
1 113
1 120
127 1
134 1
1 141
1 148
1 155
162 1
1 169
1 176
183 1
1 190
197 1
1 204
211 1
1 218
1 225
232 1
239 1
246 1
253 1
260 1
267 1
274 1
281 1
288 1
295 1
1 302
309 1
1 316
1 323
330 1
337 1
3...

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
560
144
...

result:

ok q=100000

Test #200:

score: 0
Accepted
time: 13ms
memory: 30952kb

input:

970 66182
1 2
1 5
1 7
8 1
1 15
22 1
1 29
1 36
43 1
1 57
64 1
1 71
1 78
85 1
1 92
1 99
106 1
1 113
1 120
1 127
134 1
141 1
148 1
155 1
1 162
1 169
1 176
1 183
1 190
197 1
204 1
211 1
1 218
225 1
232 1
1 239
1 246
253 1
260 1
267 1
274 1
281 1
1 288
295 1
1 302
1 309
316 1
1 323
1 330
1 337
344 1
351 ...

output:

417
969
832
279
695
558
139
557
694
418
280
3
2
831
556
277
140
416
276
415
968
278
275
141
414
967
966
555
138
419
413
412
554
553
274
693
1
552
965
964
551
550
273
411
410
272
271
963
962
961
960
137
959
270
136
692
691
409
408
830
829
828
958
690
549
548
957
135
134
547
407
827
406
405
546
826
82...

result:

ok q=100000

Test #201:

score: 0
Accepted
time: 17ms
memory: 30604kb

input:

970 66182
4 1
1 5
6 1
1 8
15 1
1 22
1 29
1 36
43 1
1 50
1 57
1 64
1 71
78 1
85 1
92 1
1 99
106 1
1 113
120 1
1 127
134 1
1 141
148 1
155 1
162 1
169 1
1 176
183 1
1 190
197 1
204 1
1 211
1 218
225 1
232 1
1 239
1 246
1 253
1 260
267 1
274 1
1 281
288 1
295 1
302 1
309 1
316 1
323 1
330 1
337 1
344 1...

output:

0
416
694
141
2
140
139
138
137
136
135
134
966
965
831
830
280
279
282
693
692
691
690
142
689
3
133
556
417
143
555
554
964
415
1
418
144
829
281
132
131
130
129
128
127
126
125
963
962
553
688
557
687
414
828
413
124
412
411
686
685
961
960
410
409
408
407
959
958
123
122
406
827
826
825
824
823
...

result:

ok q=100000

Test #202:

score: 0
Accepted
time: 20ms
memory: 32180kb

input:

970 58094
3 1
1 4
1 5
1 7
8 1
1 9
17 1
1 25
33 1
1 41
49 1
1 57
1 65
73 1
81 1
1 89
97 1
105 1
113 1
1 121
1 129
137 1
145 1
153 1
161 1
169 1
1 177
1 185
193 1
1 201
1 209
1 217
1 225
233 1
1 241
249 1
1 257
265 1
273 1
1 281
1 289
297 1
1 305
1 313
321 1
329 1
1 337
1 345
1 353
1 361
369 1
1 377
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
610
248
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 q=100000

Test #203:

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

input:

970 58094
3 1
5 1
1 9
17 1
25 1
33 1
1 41
49 1
57 1
1 65
1 73
1 81
1 89
1 97
105 1
1 113
121 1
1 129
137 1
1 145
1 153
1 161
1 169
1 177
1 185
193 1
1 201
209 1
217 1
225 1
233 1
1 241
1 249
1 257
1 265
1 273
1 281
289 1
297 1
305 1
313 1
1 321
329 1
1 337
1 345
353 1
1 361
1 369
1 377
1 385
1 393
4...

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
2
1
0
0
0
0
0
493
371
249
125
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
494
248
124
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #204:

score: 0
Accepted
time: 17ms
memory: 30176kb

input:

970 58094
2 1
5 1
1 6
7 1
1 8
1 9
17 1
25 1
1 33
41 1
1 49
1 57
1 65
1 73
1 81
89 1
97 1
1 105
113 1
1 121
1 129
137 1
1 145
1 153
1 161
1 169
1 177
1 185
193 1
1 201
209 1
217 1
1 225
233 1
241 1
1 249
257 1
265 1
273 1
1 281
1 289
297 1
305 1
1 313
321 1
329 1
337 1
345 1
1 353
1 361
369 1
377 1
1...

output:

126
369
731
3
491
249
611
851
250
248
247
971
490
732
129
610
371
730
729
370
489
488
125
609
728
608
2
246
368
4
970
969
251
124
128
487
5
727
123
367
366
1
122
486
607
127
365
364
850
849
848
245
121
120
119
244
606
243
968
726
725
605
604
603
602
118
485
484
483
242
847
241
363
362
361
117
846
11...

result:

ok q=100000

Test #205:

score: 0
Accepted
time: 16ms
memory: 30352kb

input:

970 58094
4 1
5 1
7 1
8 1
9 1
1 17
1 25
33 1
41 1
1 49
1 57
1 65
1 73
81 1
89 1
1 97
1 105
113 1
121 1
129 1
1 137
1 145
153 1
1 161
1 169
1 177
1 185
1 193
201 1
209 1
217 1
225 1
233 1
241 1
249 1
257 1
265 1
1 273
1 281
1 289
297 1
1 305
313 1
1 321
1 329
1 337
1 345
1 353
1 361
1 369
377 1
385 1...

output:

0
251
0
970
969
968
967
614
613
612
494
493
492
491
490
489
488
375
374
373
372
487
486
485
252
371
370
369
368
851
850
849
848
254
847
846
845
844
966
731
965
964
963
125
124
123
611
367
366
365
364
250
249
130
126
484
483
482
363
730
495
253
729
728
727
726
129
362
2
361
1
122
121
962
961
128
127
...

result:

ok q=100000

Extra Test:

score: 0
Extra Test Passed