QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#181443#7181. Graph Cutsucup-team570AC ✓930ms21592kbC++1718.9kb2023-09-16 19:07:532023-09-16 19:07:53

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

3
5
4
2
0
1
0

result:

ok q=10

Test #2:

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

input:

0 0
0

output:


result:

ok q=0

Test #3:

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

input:

0 0
1
?

output:

0

result:

ok q=1

Test #4:

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

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:

1998
1994
1991
1989
1986
1985
1984
1981
1979
1978
1973
1971
1970
1969
1963
1960
1957
1954
1953
1952
1951
1950
1949
1947
1942
1933
1927
1922
1920
1914
1911
1903
1895
1890
1888
1887
1886
1884
1879
1876
1866
1864
1863
1862
1854
1853
1849
1844
1839
1837
1832
1829
1828
1819
1816
1813
1807
1806
1804
1803
...

result:

ok q=100000

Test #5:

score: 0
Accepted
time: 902ms
memory: 11104kb

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:

99679

result:

ok q=100000

Test #6:

score: 0
Accepted
time: 822ms
memory: 11040kb

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:

29179
19078
19076
19075
19073
19072
19069
19065
19062
19059
9579
9577
2659
2657
2656
2654
2653
2650
2646
2643
1776
1774
1773
1771
1770
1767
1763
1333
1331
444
442
441
439
438
435
431
428
425
424
423
419
417
416
414
413
411
410
409
408
404
399
397
396
395
389
388
381
380
379
99664
99662
99661
99647
9...

result:

ok q=100000

Test #7:

score: 0
Accepted
time: 715ms
memory: 11108kb

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
11271
891
889
887
886
883
882
881
880
877
876
875
873
872
871
870
869
868
867
866
864
862
861
860
857
854
852
851
850
849
3978
3976
3974
3973
3970
3969
3968
3967
3964
3963
3962
3960
3959
3958
3957
3956
3955
3954
3953
3540
3951
3949
3948
847
845
843
839
838
836
835
832
831
830
829
827
824
823
8...

result:

ok q=100000

Test #8:

score: 0
Accepted
time: 608ms
memory: 11048kb

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
34340
34339
12110
12109
12108
12106
12104
9156
9155
9154
9152
9150
9149
9148
9146
9145
9144
9143
9142
9141
9140
9139
9137
9136
9134
9133
9132
9131
9130
9129
9128
9126
9125
9123
9122
9121
9120
9119
9117
9115
9114
9112
9111
9110
9109
9108
9107
9105
9104
9103
9102
9098
9095
9094
9093
446
445
444
442
...

result:

ok q=100000

Test #9:

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

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
33249
33248
33247
33246
33245
33243
33239
33238
33237
33236
33235
33234
33233
33232
33230
33229
33228
33226
33225
33224
33223
33222
33220
33219
33218
33217
33216
33215
33214
33213
33212
33211
33208
33207
33206
33205
33204
33202
33200
33197
33196
33195
18678
18676
18675
18674
18...

result:

ok q=100000

Test #10:

score: 0
Accepted
time: 382ms
memory: 10872kb

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
62545
62543
62542
62541
62540
62539
62538
20678
20677
20676
20675
20674
20673
20672
20670
20668
20667
20666
20665
20664
20663
20662
20661
20660
20659
20658
20657
20656
20655
20654
20653
20652
20651
20650
20649
20648
20647
20646
20645
20644
20642
2064...

result:

ok q=100000

Test #11:

score: 0
Accepted
time: 222ms
memory: 11540kb

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: 914ms
memory: 11376kb

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:

99663

result:

ok q=100000

Test #13:

score: 0
Accepted
time: 821ms
memory: 11368kb

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:

445
444
443
441
436
435
433
431
430
424
420
418
99681
99680
99674
99673
99659
99658
99652
99651
99644
99643
99636
99632
99629
99628
99627
99626
99622
99619
99618
99617
99615
99611
99608
99607
99606
99603
99599
99596
99595
99594
99589
99588
99580
99579
99578
99577
99576
99572
99569
99568
99567
99562
...

result:

ok q=100000

Test #14:

score: 0
Accepted
time: 723ms
memory: 11048kb

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:

2661
2657
2656
2654
2653
2649
2648
2640
2637
2635
2632
2626
2622
2619
2617
2616
2613
2612
2609
2608
2606
2605
2604
2599
2597
2595
2591
2589
2584
2583
2578
2577
2573
99668
99657
99640
99638
99612
99606
99585
99583
99578
99573
99567
99562
99505
99503
99498
99495
99486
99484
99479
99476
99468
99462
994...

result:

ok q=100000

Test #15:

score: 0
Accepted
time: 615ms
memory: 11000kb

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:

1335
1334
1333
1326
1325
1323
1320
1317
1314
1313
1311
1310
1309
1307
1306
1303
1301
1299
1298
1297
1295
1293
1290
1288
1287
1285
1282
1281
1277
1276
1273
1268
1267
1265
1264
1262
1261
1257
1250
1248
1247
1246
1245
1244
1243
1240
1238
1237
1236
1234
1230
1228
99675
99674
99673
99671
99670
99669
9966...

result:

ok q=100000

Test #16:

score: 0
Accepted
time: 488ms
memory: 11116kb

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:

445
442
438
436
434
432
431
430
427
422
419
416
414
413
411
409
408
407
404
401
400
399
398
396
394
392
391
390
386
382
378
377
375
367
366
365
364
362
361
360
358
357
355
349
347
346
345
343
341
338
336
335
333
331
330
329
322
321
319
316
315
311
310
307
304
99675
99673
99667
99662
99656
99641
9963...

result:

ok q=100000

Test #17:

score: 0
Accepted
time: 387ms
memory: 10960kb

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:

446
444
441
440
439
437
435
433
431
430
425
422
418
416
414
413
412
410
405
402
400
399
397
396
395
394
393
392
391
388
387
386
385
384
382
381
379
378
377
375
373
371
370
365
364
363
362
361
360
359
358
357
356
354
353
352
351
348
347
345
342
341
339
337
332
331
329
326
325
324
323
321
318
317
316
...

result:

ok q=100000

Test #18:

score: 0
Accepted
time: 294ms
memory: 11740kb

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:

446
444
443
441
440
435
434
432
430
427
424
421
420
419
418
415
414
413
412
409
406
403
397
396
393
389
388
387
385
384
381
379
375
374
373
371
370
368
366
365
364
361
359
356
355
354
353
352
350
349
347
346
345
342
341
339
337
336
335
334
332
331
330
328
327
326
324
322
321
316
313
311
310
308
307
...

result:

ok q=100000

Test #19:

score: 0
Accepted
time: 912ms
memory: 11740kb

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:

99669

result:

ok q=100000

Test #20:

score: 0
Accepted
time: 817ms
memory: 11588kb

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:

7446
7445
7443
7442
891
890
888
887
883
882
881
880
878
872
869
865
864
863
861
859
857
852
848
846
845
99491
99488
99487
99483
99482
99475
99473
99472
99428
99425
99424
99420
99419
99412
99410
99409
99336
99333
99310
99307
99255
99252
99226
99223
99216
99213
99212
99208
99207
99200
99198
99197
9919...

result:

ok q=100000

Test #21:

score: 0
Accepted
time: 718ms
memory: 11616kb

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:

891
887
885
884
881
878
877
876
875
869
868
867
863
859
858
857
856
854
845
843
841
840
839
838
837
836
833
832
831
829
822
818
814
811
810
809
803
800
798
797
796
795
794
793
790
789
787
99653
99649
99648
99646
99637
99628
99626
99622
99621
99619
99617
99616
99615
99611
99610
99608
99606
99605
9959...

result:

ok q=100000

Test #22:

score: 0
Accepted
time: 606ms
memory: 11576kb

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
33251
33250
33249
15426
15425
15424
15423
15419
12110
12109
12108
12107
12103
12102
12101
12100
12097
12096
12095
12094
12093
12092
12091
12090
12088
12087
12086
12085
12084
12083
12079
12077
12076
12073
3101
3100
3099
3098
3094
3093
3092
3091
3088
3087
3086
3085
3084
3083
3082
3081
3079
3078
30...

result:

ok q=100000

Test #23:

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

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:

81344
66010
66009
66007
66006
66005
24214
24213
24211
24210
24209
24208
24207
24205
24203
24202
24201
24200
19480
19479
16652
16651
16649
16648
6584
6583
6581
6580
6579
6578
6577
6575
6573
6572
6571
6570
6569
6563
6562
6560
6558
6556
6554
6552
6551
6550
6549
6548
6546
6544
6539
6538
6535
6534
6532
6...

result:

ok q=100000

Test #24:

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

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
94321
94319
94318
94316
59495
59494
59491
59489
59488
59486
59485
59483
59482
59480
59478
59476
59474
59473
59471
59465
59464
59463
59460
59458
59457
59456
56610
56609
56606
9581
9580
9577
9575
9574
9572
9571
9569
9568
9566
9564
9562
9560
9559
9557
9551
9550
9549
9546
9544
7016
7...

result:

ok q=100000

Test #25:

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

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: 930ms
memory: 11044kb

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:

99989

result:

ok q=100000

Test #27:

score: 0
Accepted
time: 831ms
memory: 11216kb

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
32188
2221
2215
2214
2212
2208
2205
2204
2203
2196
2195
2194
2193
2190
2189
1778
1772
1771
1769
1765
1762
892
886
885
883
879
876
875
874
867
866
865
864
861
860
857
855
854
851
99986
99980
99959
99950
99930
99928
99925
99924
99904
99897
99891
99889
99886
99885
99881
99859
99852
99849
99...

result:

ok q=100000

Test #28:

score: 0
Accepted
time: 728ms
memory: 11120kb

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:

3106
3103
3102
3101
3100
3099
3096
3095
3094
3092
3091
3090
3089
3085
3084
3083
3082
3081
3080
3079
3076
1337
1334
1333
1332
1331
1330
1327
1326
1325
1323
1322
1321
1320
1316
1315
1314
1313
1312
1311
1310
1307
1306
1302
1301
1299
1297
1295
1294
1293
1291
1290
1289
1288
1287
1286
1285
1284
1283
1282
...

result:

ok q=100000

Test #29:

score: 0
Accepted
time: 615ms
memory: 11132kb

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:

98103
98102
98101
98100
98098
1329
1328
1327
1326
1324
1322
1320
1318
1317
1315
1313
1311
1310
1309
1307
1306
1305
1303
1302
1301
1298
1297
1296
1295
1293
1292
1290
1289
1287
1286
1285
1284
1282
1279
1278
1277
1276
1273
1272
1271
1270
1268
1267
1266
1265
1264
1262
1260
1259
1258
1257
1256
1253
1252
...

result:

ok q=100000

Test #30:

score: 0
Accepted
time: 486ms
memory: 10956kb

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
79919
79917
79916
79914
79913
51230
51229
51228
51227
51226
51225
51223
51222
46110
46109
46108
31452
31451
31450
31449
31448
31447
31445
31444
31442
31441
31440
31439
31437
31436
31435
31434
31432
31431
31430
31427
31426
31425
31424
31422
31420
31419
31418
31417
3141...

result:

ok q=100000

Test #31:

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

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
73923
73922
73921
73920
73919
73916
73915
73914
73913
73912
73911
73910
21492
21491
21490
21489
21488
21485
21484
21483
21482
21481
21480
21479
21478
21477
21476
21475
21471
21470
21469
21468
21467
21466
21465
21464
5727
5726
5725
5724
5723
5720
5719
5718
5717
5716
5715
5714
5713
5712
57...

result:

ok q=100000

Test #32:

score: 0
Accepted
time: 215ms
memory: 11324kb

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: 929ms
memory: 11396kb

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:

99998

result:

ok q=100000

Test #34:

score: 0
Accepted
time: 831ms
memory: 11308kb

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:

1773
1771
1770
1769
1763
1762
1759
439
437
436
435
429
428
99989
99986
99963
99960
99944
99941
99918
99914
99912
99891
99887
99885
99843
99839
99837
99786
99782
99780
99765
99761
99759
99720
99716
99714
99594
99591
99582
99580
99577
99574
99573
99571
99472
99469
99460
99458
99455
99452
99451
99449
9...

result:

ok q=100000

Test #35:

score: 0
Accepted
time: 728ms
memory: 11156kb

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:

445
442
441
438
433
430
425
423
422
418
417
414
413
410
407
406
405
404
401
400
398
395
394
99999
99998
99995
99990
99989
99987
99953
99950
99932
99929
99909
99908
99906
99899
99897
99864
99863
99861
99854
99852
99827
99824
99815
99812
99808
99805
99796
99793
99745
99742
99733
99730
99724
99723
9972...

result:

ok q=100000

Test #36:

score: 0
Accepted
time: 609ms
memory: 11108kb

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:

443
441
440
438
437
436
434
432
429
428
426
425
424
421
420
419
418
417
411
407
404
402
401
400
399
395
393
391
390
389
387
386
385
384
377
370
365
364
359
358
353
348
347
346
342
341
339
338
335
99994
99991
99990
99987
99981
99980
99979
99976
99973
99951
99950
99948
99945
99942
99939
99935
99930
99...

result:

ok q=100000

Test #37:

score: 0
Accepted
time: 502ms
memory: 11048kb

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:

447
446
445
442
441
438
436
435
433
430
429
428
427
423
420
419
417
416
414
410
409
407
406
405
403
402
400
397
396
395
393
392
390
389
387
386
383
382
381
377
374
372
368
365
363
358
356
351
350
349
348
346
344
341
340
338
336
335
333
332
324
323
322
321
99994
99992
99986
99981
99979
99977
99974
99...

result:

ok q=100000

Test #38:

score: 0
Accepted
time: 387ms
memory: 11088kb

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:

447
446
445
440
439
438
436
435
434
431
427
425
420
419
417
416
414
411
410
407
406
405
403
401
400
397
396
395
392
391
389
388
387
382
381
378
375
372
370
368
365
364
362
361
359
357
356
353
351
349
348
347
346
345
340
338
337
336
335
334
330
328
326
323
319
317
316
315
314
313
311
309
99997
99996
...

result:

ok q=100000

Test #39:

score: 0
Accepted
time: 293ms
memory: 11648kb

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:

446
444
443
442
441
439
437
435
434
432
429
428
426
424
423
421
417
416
415
411
410
409
408
407
405
404
403
402
399
396
392
387
386
382
381
379
378
376
375
372
371
363
361
356
354
353
351
350
349
345
343
341
338
337
336
334
332
330
328
327
326
325
324
320
319
318
317
316
310
309
307
306
304
303
301
...

result:

ok q=100000

Test #40:

score: 0
Accepted
time: 922ms
memory: 11744kb

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:

99979

result:

ok q=100000

Test #41:

score: 0
Accepted
time: 824ms
memory: 11636kb

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
1781
1778
1777
1775
1771
1769
1768
1765
1762
1761
1760
1759
1756
1755
1754
1753
1750
1745
1744
1741
1737
1732
1731
1728
1727
1726
1725
1723
1722
1721
1719
1718
99996
99993
99954
99944
99933
99894
99879
99861
99860
99854
99853
99852
99849
99848
99844
99843
99837
99836
99835
99832
99831
99744
99...

result:

ok q=100000

Test #42:

score: 0
Accepted
time: 719ms
memory: 11680kb

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
14199
8739
8734
8731
8728
8725
8723
8721
8720
3107
3102
3099
3096
3093
3091
3089
3088
3087
3085
3081
3080
3079
3077
3076
3075
3074
3073
3072
3071
3067
3064
3062
3061
3060
3059
3058
3056
3055
3053
3052
3051
3049
3048
3046
3043
3042
3041
3039
3038
3037
3036
3034
3033
3032
3031
3027
3025
3024
3017
30...

result:

ok q=100000

Test #43:

score: 0
Accepted
time: 618ms
memory: 11628kb

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
65320
65316
65313
65310
65308
65307
65305
65303
65302
6593
6591
6587
6584
6581
6579
6578
6576
6574
6573
6568
6566
6565
6564
6562
6561
1337
1335
1331
1328
1325
1323
1322
1320
1318
1317
1312
1310
1309
1308
1306
1305
1300
1299
1296
1295
1294
1291
1285
1284
1282
1281
1280
1279
1277
1...

result:

ok q=100000

Test #44:

score: 0
Accepted
time: 493ms
memory: 11744kb

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:

43118
43117
43115
43114
43111
41419
41418
41416
41415
41412
41410
41409
41407
41404
41403
41402
41400
41399
41398
41397
4856
4855
4853
4852
4849
4847
4846
4844
4841
4840
4839
4837
4836
4835
4834
4833
4832
4831
4830
4829
4828
4827
4825
4822
4820
4819
4818
4815
4814
891
890
888
887
884
882
881
879
876...

result:

ok q=100000

Test #45:

score: 0
Accepted
time: 387ms
memory: 11636kb

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
75268
75266
75265
75261
75260
75259
75257
75256
75255
75254
75253
75251
75248
53088
53087
38653
38652
38650
38648
38647
38643
38642
38641
38639
38638
38637
38636
38635
38633
38630
38628
38626
38625
38624
38622
38620
38619
38618
38617
38616
38611
38610
38609
38607
38605
38604
38602
3860...

result:

ok q=100000

Test #46:

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

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: 791ms
memory: 20356kb

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:

99998

result:

ok q=100000

Test #48:

score: 0
Accepted
time: 744ms
memory: 20496kb

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
48488
30538
13514
13513
13512
12375
27931
27930
27929
26264
17100
21768
21767
21766
5804
13990
13989
21765
21764
19557
24025
17392
17391
18081
18080
1845
1844
18079
18078
5177
5176
9930
15971
15970
18077
19187
8664
1084
24252
24251
8756
25213
25212
541
540
539
901
900
24798
25457
25456
1...

result:

ok q=100000

Test #49:

score: 0
Accepted
time: 667ms
memory: 20844kb

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:

45530
31730
15691
15690
254
253
252
251
250
249
4317
4316
12013
15689
8020
8019
8018
15688
16068
16067
16066
16065
23848
23847
27768
27767
28826
32562
29360
36043
38578
38577
10188
39034
39033
39032
39031
24130
41137
41136
41930
10520
42830
42829
42932
43311
43310
6715
6714
15719
15718
35853
2198
39...

result:

ok q=100000

Test #50:

score: 0
Accepted
time: 590ms
memory: 18764kb

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:

49551
49550
49549
11901
50261
40431
71478
71477
58649
52035
35164
14556
3271
3270
3269
3268
14555
33488
31355
31354
35454
35453
35452
48037
26073
18489
50164
34109
41209
45418
17118
76160
76839
3678
76838
22738
22737
33368
33367
21390
63519
63518
57130
29370
36518
78771
55848
55847
16898
12467
16897...

result:

ok q=100000

Test #51:

score: 0
Accepted
time: 532ms
memory: 19020kb

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
25083
25082
25081
38372
38371
19896
19895
38370
64094
56000
3296
12956
12955
12954
9074
9128
9127
9126
12953
6360
76367
61668
43568
8056
62238
62237
28457
48282
14145
34967
81470
81469
81468
28482
845
90105
88273
88272
67816
59096
40004
35692
11407
90104
90103
90102
2...

result:

ok q=100000

Test #52:

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

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: 424ms
memory: 19020kb

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: 865ms
memory: 20460kb

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:

100000

result:

ok q=100000

Test #55:

score: 0
Accepted
time: 868ms
memory: 21592kb

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:

99999
99997
99993
99990
99984
99983
99982
99980
99979
99977
99976
99974
99971
99970
99969
99965
99963
99962
99959
99958
99956
99952
99949
99947
99944
99943
99942
99941
99939
99937
99933
99932
99929
99927
99926
99924
99923
99922
99919
99918
99916
99914
99911
99906
99904
99901
99899
99898
99895
99894
...

result:

ok q=100000

Test #56:

score: 0
Accepted
time: 839ms
memory: 20452kb

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:

100000
99999
99995
99992
99991
99990
99987
99985
99983
99981
99980
99979
99977
99976
99975
99972
99971
99970
99969
99966
99963
99962
99961
99959
99958
99957
99955
99950
99948
99947
99946
99944
99943
99942
99940
99938
99935
99934
99933
99931
99926
99922
99919
99918
99915
99914
99912
99911
99909
99906...

result:

ok q=100000

Test #57:

score: 0
Accepted
time: 829ms
memory: 20360kb

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:

100000
99999
99998
99997
99996
99994
99993
99990
99989
99985
99983
99982
99981
99979
99978
99976
99972
99969
99967
99963
99961
99960
99959
99958
99950
99949
99948
99947
99946
99944
99942
99938
99937
99935
99934
99927
99926
99924
99922
99921
99920
99918
99915
99912
99910
99908
99905
99904
99903
99902...

result:

ok q=100000

Test #58:

score: 0
Accepted
time: 824ms
memory: 20576kb

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:

99998
99993
99992
99989
99988
99987
99986
99985
99984
99983
99982
99981
99980
99977
99976
99973
99972
99970
99966
99965
99963
99961
99959
99958
99956
99951
99950
99949
99948
99946
99945
99944
99943
99941
99939
99936
99935
99930
99923
99922
99921
99913
99912
99911
99910
99906
99905
99901
99899
99896
...

result:

ok q=100000

Test #59:

score: 0
Accepted
time: 813ms
memory: 20448kb

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:

100000
99999
99997
99992
99991
99990
99988
99985
99982
99978
99977
99976
99973
99972
99971
99970
99966
99962
99961
99960
99958
99957
99955
99952
99951
99950
99949
99947
99942
99939
99938
99936
99935
99932
99930
99928
99927
99923
99922
99921
99920
99914
99913
99911
99907
99905
99903
99902
99900
99899...

result:

ok q=100000

Test #60:

score: 0
Accepted
time: 804ms
memory: 20784kb

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:

99998
99997
99996
99995
99994
99992
99990
99988
99987
99983
99982
99981
99980
99978
99977
99976
99974
99973
99971
99965
99964
99963
99962
99957
99954
99953
99951
99950
99948
99942
99938
99931
99929
99926
99923
99920
99919
99918
99915
99914
99913
99910
99907
99905
99903
99901
99900
99898
99897
99895
...

result:

ok q=100000

Test #61:

score: 0
Accepted
time: 778ms
memory: 20704kb

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: 766ms
memory: 20484kb

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: 765ms
memory: 20960kb

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: 771ms
memory: 20476kb

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: 775ms
memory: 21060kb

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: 758ms
memory: 20636kb

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: 772ms
memory: 20676kb

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: 512ms
memory: 20940kb

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: 428ms
memory: 19596kb

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: 614ms
memory: 19228kb

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:

99969
0
99968
0
99967
0
99966
0
99965
0
99964
0
99963
0
99962
0
99961
0
99960
0
99959
0
99958
0
99957
0
99956
0
99955
0
99954
0
99953
0
99952
0
99951
0
99950
0
99949
0
99948
0
99947
0
99946
0
99945
0
99944
0
99943
0
99942
0
99941
0
99940
0
99939
0
99938
0
99937
0
99936
0
99935
0
99934
0
99933
0
9993...

result:

ok q=100000

Test #71:

score: 0
Accepted
time: 607ms
memory: 19064kb

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
99969
99968
99967
99966
0
99965
0
0
0
99964
99963
99962
0
0
99961
0
99960
99959
99958
99957
0
99956
0
99955
0
99954
0
0
99953
0
99952
0
0
99951
0
0
99950
99949
99948
0
0
99947
0
0
99946
0
99945
0
0
0
99944
99943
0
0
0
99942
0
0
99941
0
0
0
99940
0
0
0
99939
0
99938
99937
0
0
0
99936
0
99935
0
0
0
...

result:

ok q=100000

Test #72:

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

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: 471ms
memory: 20784kb

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: 544ms
memory: 18800kb

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:

99969
49985
49984
49983
99968
0
99967
49982
49981
49980
99966
0
49979
0
49978
49977
99965
0
99964
0
49976
49975
99963
0
99962
49974
99961
49973
99960
49972
49971
49970
49969
49968
99959
49967
49966
49965
49964
0
49963
49962
99958
49961
99957
0
99956
49960
99955
0
49959
49958
49957
0
49956
0
99954
0
...

result:

ok q=100000

Test #75:

score: 0
Accepted
time: 558ms
memory: 18724kb

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
99969
99968
99967
99966
99965
99964
99963
0
49985
0
0
99962
99961
49984
49983
0
0
0
0
0
0
49982
49981
49980
49979
49978
49977
49976
99960
49975
49974
49973
49972
99959
99958
99957
99956
99955
0
99954
0
0
0
0
99953
0
49971
49970
49969
49968
99952
49967
49966
99951
99950
99949
49965
49964
49963
...

result:

ok q=100000

Test #76:

score: 0
Accepted
time: 446ms
memory: 20696kb

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: 443ms
memory: 20824kb

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: 576ms
memory: 18808kb

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:

33324
0
99969
33323
99968
0
66647
66646
66645
33322
66644
33321
66643
66642
66641
0
33320
33319
33318
33317
33316
66640
33315
66639
33314
33313
66638
33312
66637
33311
66636
33310
33309
33308
33307
33306
33305
66635
66634
33304
66633
66632
33303
33302
33301
33300
66631
66630
33299
33298
33297
33296
...

result:

ok q=100000

Test #79:

score: 0
Accepted
time: 519ms
memory: 18696kb

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:

33325
33324
33323
33322
0
0
0
0
0
0
33321
33320
0
0
0
0
0
0
0
66647
33319
33318
33317
33316
33315
33314
33313
66646
66645
66644
66643
66642
33312
33311
33310
33309
33308
33307
33306
33305
33304
33303
66641
66640
66639
33302
33301
33300
33299
33298
33297
33296
33295
33294
33293
33292
33291
33290
3328...

result:

ok q=100000

Test #80:

score: 0
Accepted
time: 442ms
memory: 20688kb

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: 461ms
memory: 20780kb

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: 576ms
memory: 18784kb

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:

49987
24993
24992
49986
99969
0
74978
0
24991
24990
99968
0
24989
24988
24987
0
24986
24985
24984
24983
24982
74977
99967
0
74976
49985
74975
0
49984
49983
49982
49981
99966
0
24981
24980
24979
24978
24977
24976
24975
74974
74973
74972
74971
0
74970
24974
24973
24972
24971
24970
49980
49979
74969
24...

result:

ok q=100000

Test #83:

score: 0
Accepted
time: 533ms
memory: 18804kb

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:

99969
24993
99968
49986
49985
99967
0
0
24992
24991
0
74978
74977
24990
24989
24988
49984
49983
49982
49981
49980
74976
74975
24987
24986
24985
24984
24983
24982
24981
24980
24979
49979
49978
49977
49976
49975
49974
49973
24978
49972
49971
24977
24976
24975
24974
24973
49970
49969
49968
49967
49966
...

result:

ok q=100000

Test #84:

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

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: 428ms
memory: 18864kb

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: 576ms
memory: 18808kb

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:

79977
59983
59982
59981
79976
19996
19995
39990
19994
19993
19992
19991
19990
19989
79975
59980
79974
19988
19987
19986
19985
19984
99970
19983
19982
19981
19980
19979
19978
39989
39988
39987
19977
19976
99969
39986
99968
19975
19974
79973
19973
19972
19971
59979
99967
59978
39985
39984
39983
59977
...

result:

ok q=100000

Test #87:

score: 0
Accepted
time: 518ms
memory: 18728kb

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:

59983
59982
0
39989
39988
39987
39986
39985
0
0
0
0
0
39984
19995
19994
19993
19992
19991
19990
19989
19988
19987
19986
19985
19984
19983
39983
39982
39981
39980
39979
39978
39977
39976
39975
0
39974
39973
39972
39971
19982
19981
39970
39969
39968
39967
39966
19980
19979
19978
19977
19976
19975
1997...

result:

ok q=100000

Test #88:

score: 0
Accepted
time: 436ms
memory: 20844kb

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: 439ms
memory: 19392kb

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: 551ms
memory: 18688kb

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:

99972
83312
33326
33325
33324
49988
99971
66651
99970
0
66650
66649
49987
49986
49985
33323
33322
33321
33320
33319
33318
16664
16663
16662
16661
33317
33316
16660
16659
49984
49983
66648
66647
0
99969
33315
33314
33313
99968
83311
83310
0
66646
66645
66644
66643
49982
33312
33311
49981
49980
16658
...

result:

ok q=100000

Test #91:

score: 0
Accepted
time: 516ms
memory: 18868kb

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:

33327
33326
33325
33324
16663
16662
16661
16660
16659
16658
16657
16656
16655
16654
16653
49990
49989
49988
49987
49986
16652
16651
16650
16649
16648
16647
16646
16645
16644
16643
16642
16641
16640
16639
16638
16637
16636
16635
16634
16633
33323
33322
49985
49984
66652
66651
66650
66649
16632
16631
...

result:

ok q=100000

Test #92:

score: 0
Accepted
time: 429ms
memory: 19424kb

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: 415ms
memory: 18984kb

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: 528ms
memory: 18632kb

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:

99974
71414
99973
42852
28569
14285
14284
42851
42850
28568
28567
14283
14282
42849
14281
14280
14279
14278
14277
14276
14275
14274
14273
14272
14271
14270
57134
28566
28565
28564
28563
28562
28561
28560
28559
28558
28557
28556
28555
71413
28554
28553
28552
28551
28550
28549
57133
14269
14268
85694
...

result:

ok q=100000

Test #95:

score: 0
Accepted
time: 493ms
memory: 18708kb

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
85694
85693
85692
42851
42850
42849
42848
42847
85691
85690
42846
42845
42844
42843
42842
42841
85689
85688
85687
85686
85685
85684
85683
71414
14286
14285
14284
14283
14282
14281
42840
42839
42838
42837
42836
42835
42834
42833
42832
42831
42830
42829
42828
42827
42826
42825
42824
42823
42822
42...

result:

ok q=100000

Test #96:

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

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: 436ms
memory: 20948kb

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: 550ms
memory: 18528kb

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:

49994
25000
24999
24998
12499
12498
12497
12496
24997
37497
49993
49992
49991
49990
62490
74986
12495
12494
12493
12492
12491
12490
12489
12488
12487
12486
12485
12484
12483
12482
12481
12480
12479
12478
12477
12476
24996
24995
24994
12475
12474
12473
12472
12471
12470
12469
37496
12468
12467
12466
...

result:

ok q=100000

Test #99:

score: 0
Accepted
time: 500ms
memory: 18684kb

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
62488
62487
62486
62485
62484
24999
24998
24997
24996
24995
24994
74985
74984
74983
12497
12496
74982
74981
87481
74980
74979
74978
74977
74976
74975
87480
87479
49992
12495
12494
12493
12492
12491
12490
12489
12488
12487
12486
12485
12484
12483
12482
12481
12480
12479
49991
49990
49989
49988
...

result:

ok q=100000

Test #100:

score: 0
Accepted
time: 634ms
memory: 12012kb

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:

99999

result:

ok q=100000

Test #101:

score: 0
Accepted
time: 580ms
memory: 11684kb

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:

3268
3267
3266
3265
3264
3263
3262
3261
3260
3259
3258
3257
3256
3255
3254
3253
3252
3251
3250
3249
3248
5914
5913
5912
741
740
739
738
737
736
735
734
733
732
731
730
729
728
727
726
725
724
2753
2752
2751
2750
2749
2748
2747
2746
2745
2744
2743
2742
99993
99988
99923
99919
99910
99860
99857
99825
...

result:

ok q=100000

Test #102:

score: 0
Accepted
time: 518ms
memory: 11592kb

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
7024
7023
7022
7021
4817
4816
4815
4814
693
692
691
690
689
688
687
686
685
684
683
682
681
2420
2419
2418
2417
2416
2415
2414
2413
2412
2411
2410
2409
2408
2407
2406
2405
2404
2403
2402
2401
3625
3624
3623
3622
3621
3620
3619
3618
3617
3616
2574
2573
2572
2571
2570
2569
2181
2180
2179
2178
...

result:

ok q=100000

Test #103:

score: 0
Accepted
time: 461ms
memory: 11660kb

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
35206
35205
35204
35203
35202
35201
5416
5415
5414
5413
5411
5410
5409
5408
5407
5406
5405
5404
5403
5402
5401
5400
5399
5398
5397
5396
1807
6668
6667
6666
6665
6664
6663
6662
6661
6660
6659
6658
6657
6656
6655
6654
6653
1471
1182
494
24588
6373
5010
5009
5008
5007
5006
5005
5004
5003
5002
5...

result:

ok q=100000

Test #104:

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

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
42785
42784
42783
42782
42781
24099
24098
24097
23462
23461
23460
23459
23458
23457
23456
23455
23454
23453
23452
23451
23450
23449
23448
23447
23446
23445
23444
23443
23442
13747
9907
13540
9286
9285
9284
9283
9282
9281
9280
9279
9278
9277
9276
9275
9274
9273
9...

result:

ok q=100000

Test #105:

score: 0
Accepted
time: 330ms
memory: 12180kb

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
68518
68517
65458
64972
61923
59698
58998
57930
9545
9544
9543
9542
9541
9540
9539
9538
9537
9536
9535
9534
9533
9532
9531
9530
9529
9528
9527
2886
47799
47798
47797
47796
...

result:

ok q=100000

Test #106:

score: 0
Accepted
time: 238ms
memory: 12116kb

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: 638ms
memory: 11852kb

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:

99998

result:

ok q=100000

Test #108:

score: 0
Accepted
time: 582ms
memory: 12048kb

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:

99999
99998
99996
99995
99993
99992
99991
99990
99989
99986
99985
99981
99980
99979
99978
99973
99971
99967
99965
99964
99962
99959
99957
99952
99946
99943
99941
99937
99936
99935
99932
99931
99927
99926
99925
99918
99917
99914
99912
99911
99910
99909
99908
99907
99905
99903
99901
99891
99888
99887
...

result:

ok q=100000

Test #109:

score: 0
Accepted
time: 543ms
memory: 11840kb

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:

100000
99997
99996
99994
99992
99991
99988
99986
99985
99984
99980
99974
99971
99969
99968
99965
99959
99951
99947
99943
99970
99949
99948
99944
99942
99940
99939
99938
99935
99934
99932
99930
99929
99928
99925
99922
99921
99918
99915
99914
99913
99909
99907
99905
99903
99900
99898
99896
99895
99894...

result:

ok q=100000

Test #110:

score: 0
Accepted
time: 487ms
memory: 12008kb

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:

100000
99998
99997
99996
99994
99991
99990
99988
99987
99986
99985
99983
99982
99977
99976
99974
99971
99966
99962
99961
99959
99957
99952
99951
99950
99946
99940
99939
99934
99933
99932
99931
99928
99925
99923
99917
99915
99912
99911
99910
99909
99908
99906
99905
99902
99899
99897
99896
99893
99884...

result:

ok q=100000

Test #111:

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

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:

100000
99999
99997
99996
99994
99992
99987
99984
99979
99978
99977
99975
99973
99970
99968
99967
99966
99964
99963
99962
99961
99959
99956
99955
99951
99950
99949
99947
99945
99944
99940
99939
99935
99934
99933
99931
99943
99941
99930
99928
99927
99924
99923
99922
99921
99919
99914
99910
99908
99904...

result:

ok q=100000

Test #112:

score: 0
Accepted
time: 406ms
memory: 12220kb

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:

100000
99998
99996
99995
99994
99993
99992
99991
99989
99988
99987
99985
99984
99982
99981
99980
99979
99978
99977
99968
99963
99962
99960
99959
99957
99955
99953
99951
99948
99945
99944
99943
99941
99940
99936
99932
99930
99928
99923
99921
99918
99914
99911
99976
99956
99938
99912
99909
99908
99907...

result:

ok q=100000

Test #113:

score: 0
Accepted
time: 365ms
memory: 12212kb

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:

100000
99997
99994
99986
99985
99984
99983
99982
99981
99979
99975
99973
99969
99965
99964
99961
99959
99956
99955
99954
99953
99952
99951
99950
99949
99946
99944
99943
99942
99940
99939
99937
99936
99935
99933
99929
99927
99925
99924
99922
99921
99920
99918
99917
99914
99913
99911
99910
99908
99902...

result:

ok q=100000

Test #114:

score: 0
Accepted
time: 615ms
memory: 11856kb

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:

99998

result:

ok q=100000

Test #115:

score: 0
Accepted
time: 573ms
memory: 11992kb

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:

2434
2433
2432
2431
2430
2429
2428
2427
99994
99991
99988
99946
99869
99850
99816
99811
99771
99766
99612
99590
99436
99323
99310
99309
99291
99283
99180
99141
99069
99025
98950
98933
98932
98873
98872
98830
98824
98783
98738
98603
98574
98539
98450
98408
98346
98333
98315
98269
98171
98092
98077
98...

result:

ok q=100000

Test #116:

score: 0
Accepted
time: 527ms
memory: 11928kb

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
42831
42830
42829
42828
42827
42826
6778
6777
6776
6775
6774
6773
6772
6770
6769
2955
2954
2953
2952
2951
2950
2949
2948
2947
2946
2945
2944
2943
2942
2941
2940
2939
99870
99869
99856
99570
99525
99520
99506
99356
99351
99287
99239
99210
99209
98981
98952
98899
98798
98792
98737
98562
...

result:

ok q=100000

Test #117:

score: 0
Accepted
time: 483ms
memory: 11920kb

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
3877
3876
3875
3874
3873
3872
3871
3870
3869
3868
3867
3865
3864
3862
3861
3860
6147
6146
6144
6143
6142
6141
6140
6139
6138
6137
6136
6135
6134
6133
6132
6131
4294
8980
8979
8978
8976
8975
8974
8973
8972
8971
8970
8969
8968
8967
8966
8965
8964
8963
8962
8961
13136
13135
13134
13133
13132
99...

result:

ok q=100000

Test #118:

score: 0
Accepted
time: 429ms
memory: 11924kb

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
29977
29976
29975
29974
29973
21450
21449
21448
11220
11219
11218
11217
11216
11215
11214
11213
11212
11211
11210
11209
11208
10929
7597
19937
19936
19935
19934
19933
19932
19931
19930
19929
19928
19927
19926
19925
19924
19923
19922
19921
19920
19919
19918
15330
2766
21447
21446
21445
21...

result:

ok q=100000

Test #119:

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

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
42533
42532
42531
42530
42529
42528
42527
42526
42525
42524
42523
42522
42521
38728
13776
13775
13774
13773
13772
13771
13770
13769
13768
13766
13764
19229
12294
6177
4129
53540
53539
53538
53537
53536
53535
53534
53533
53531
53530
49179
48024
42879
20671
19563
...

result:

ok q=100000

Test #120:

score: 0
Accepted
time: 266ms
memory: 12148kb

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: 298ms
memory: 12204kb

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: 381ms
memory: 11848kb

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: 225ms
memory: 11260kb

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:

9969
0
9968
0
9967
0
9966
0
9965
0
9964
0
9963
0
9962
0
9961
0
9960
0
9959
0
9958
0
9957
0
9956
0
9955
0
9954
0
9953
0
9952
0
9951
0
9950
0
9949
0
9948
0
9947
0
9946
0
9945
0
9944
0
9943
0
9942
0
9941
0
9940
0
9939
0
9938
0
9937
0
9936
0
9935
0
9934
0
9933
0
9932
0
9931
0
9930
0
9929
0
9928
0
9927
0...

result:

ok q=100000

Test #124:

score: 0
Accepted
time: 223ms
memory: 11456kb

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:

9969
9968
0
9967
0
9966
9965
0
9964
9963
0
0
9962
0
0
0
9961
0
0
9960
9959
0
0
0
9958
9957
0
9956
9955
9954
9953
9952
9951
9950
0
0
9949
9948
9947
9946
9945
0
9944
0
0
0
0
9943
9942
9941
0
9940
9939
0
0
0
0
0
0
9938
0
9937
0
9936
9935
9934
9933
9932
9931
0
0
0
0
0
0
0
0
9930
0
9929
0
0
9928
9927
992...

result:

ok q=100000

Test #125:

score: 0
Accepted
time: 320ms
memory: 11940kb

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: 355ms
memory: 11640kb

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: 229ms
memory: 11356kb

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:

4985
0
9969
4984
4983
4982
4981
0
9968
4980
9967
4979
4978
4977
4976
0
9966
0
9965
0
9964
4975
9963
4974
9962
4973
9961
0
9960
0
4972
4971
9959
4970
4969
0
9958
4968
4967
0
4966
4965
4964
0
4963
4962
9957
4961
9956
4960
4959
0
9955
0
9954
0
9953
0
9952
0
4958
4957
4956
0
4955
0
4954
4953
9951
4952
4...

result:

ok q=100000

Test #128:

score: 0
Accepted
time: 217ms
memory: 11516kb

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
9969
9968
9967
9966
4985
4984
9965
4983
4982
9964
9963
9962
0
4981
4980
9961
9960
4979
4978
4977
4976
4975
4974
4973
4972
4971
4970
4969
0
4968
0
9959
9958
4967
4966
0
0
4965
4964
4963
9957
0
9956
0
0
4962
4961
0
0
0
0
0
0
4960
4959
4958
4957
4956
4955
4954
4953
9955
9954
9953
9952
0
0
4952
...

result:

ok q=100000

Test #129:

score: 0
Accepted
time: 324ms
memory: 11956kb

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: 348ms
memory: 11488kb

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: 220ms
memory: 11180kb

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:

9969
3325
9968
3324
9967
6647
9966
0
6646
6645
6644
3323
3322
6643
6642
3321
6641
3320
6640
6639
9965
3319
9964
6638
6637
3318
3317
3316
9963
0
9962
3315
3314
3313
3312
3311
3310
3309
6636
3308
6635
0
9961
6634
6633
0
9960
0
6632
3307
6631
3306
6630
3305
3304
6629
3303
3302
3301
6628
6627
0
6626
662...

result:

ok q=100000

Test #132:

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

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:

9969
3325
9968
6647
9967
9966
0
0
6646
6645
6644
3324
6643
6642
6641
6640
3323
6639
6638
6637
6636
6635
3322
3321
3320
3319
3318
3317
3316
3315
3314
3313
3312
6634
3311
3310
3309
3308
3307
3306
3305
3304
3303
6633
9965
9964
0
0
6632
3302
6631
6630
6629
6628
6627
6626
6625
6624
9963
3301
3300
3299
32...

result:

ok q=100000

Test #133:

score: 0
Accepted
time: 306ms
memory: 11516kb

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: 330ms
memory: 11584kb

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: 223ms
memory: 11356kb

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:

7478
2493
2492
2491
2490
2489
2488
2487
2486
2485
4987
4986
4985
4984
2484
2483
2482
2481
9969
7477
7476
0
7475
4983
2480
2479
2478
4982
4981
4980
7474
7473
9968
4979
9967
2477
9966
0
7472
7471
7470
7469
4978
4977
4976
2476
4975
7468
7467
4974
4973
4972
4971
4970
4969
4968
4967
4966
4965
7466
2475
2...

result:

ok q=100000

Test #136:

score: 0
Accepted
time: 212ms
memory: 11456kb

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
9969
9968
7478
7477
7476
7475
9967
4986
4985
4984
2493
2492
2491
2490
2489
2488
2487
9966
7474
7473
7472
9965
9964
7471
7470
9963
7469
7468
9962
9961
2486
9960
7467
2485
2484
2483
4983
4982
4981
2482
2481
2480
2479
2478
2477
2476
0
0
7466
7465
7464
7463
7462
0
0
0
2475
2474
2473
2472
2471
24...

result:

ok q=100000

Test #137:

score: 0
Accepted
time: 299ms
memory: 11516kb

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: 323ms
memory: 11632kb

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: 223ms
memory: 11356kb

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:

5983
0
9970
7977
9969
5982
5981
5980
1994
5979
1993
1992
1991
1990
1989
5978
5977
1988
1987
1986
1985
1984
3989
3988
3987
3986
5976
5975
1983
1982
1981
5974
7976
0
1980
0
9968
3985
1979
1978
1977
1976
1975
1974
7975
0
1973
0
3984
3983
3982
1972
1971
1970
1969
5973
5972
3981
1968
1967
1966
1965
1964
...

result:

ok q=100000

Test #140:

score: 0
Accepted
time: 233ms
memory: 11508kb

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
7977
7976
7975
7974
7973
7972
3989
7971
7970
7969
7968
3988
3987
3986
3985
3984
3983
3982
3981
3980
7967
7966
7965
1995
1994
1993
1992
1991
1990
1989
1988
1987
1986
1985
1984
1983
1982
1981
1980
1979
1978
1977
1976
1975
1974
1973
1972
1971
1970
1969
1968
1967
1966
1965
1964
1963
1962
1961
1960
195...

result:

ok q=100000

Test #141:

score: 0
Accepted
time: 307ms
memory: 11592kb

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: 315ms
memory: 11524kb

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: 225ms
memory: 11196kb

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:

8312
0
3328
3327
3326
1664
1663
1662
3325
3324
3323
3322
1661
1660
1659
1658
1657
1656
1655
1654
1653
1652
1651
1650
1649
1648
1647
1646
1645
1644
1643
1642
6651
4989
4988
4987
6650
4986
6649
4985
4984
6648
1641
1640
9972
4983
1639
1638
1637
1636
1635
3321
4982
1634
1633
4981
4980
6647
4979
6646
664...

result:

ok q=100000

Test #144:

score: 0
Accepted
time: 223ms
memory: 11604kb

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:

1664
1663
1662
1661
1660
1659
1658
1657
1656
1655
1654
1653
1652
1651
1650
1649
1648
1647
1646
1645
4989
4988
1644
1643
1642
1641
1640
1639
1638
1637
1636
1635
1634
1633
1632
1631
6651
6650
6649
9972
8312
3326
8311
8310
8309
6648
6647
6646
6645
4987
4986
4985
4984
4983
4982
4981
4980
4979
1630
4978
...

result:

ok q=100000

Test #145:

score: 0
Accepted
time: 310ms
memory: 11520kb

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: 321ms
memory: 11668kb

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: 236ms
memory: 11268kb

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:

2854
1427
1426
1425
1424
1423
1422
2853
2852
5702
4278
4277
1421
1420
1419
1418
1417
5701
5700
2851
2850
2849
2848
4276
4275
4274
1416
1415
1414
0
1413
1412
8551
2847
1411
1410
1409
4273
1408
1407
1406
1405
1404
1403
1402
1401
1400
1399
1398
2846
2845
2844
2843
2842
5699
7127
4272
1397
1396
7126
569...

result:

ok q=100000

Test #148:

score: 0
Accepted
time: 238ms
memory: 11452kb

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
9974
4278
2853
2852
2851
2850
1426
1425
1424
1423
1422
1421
1420
1419
1418
1417
1416
1415
2849
2848
2847
2846
2845
9973
9972
9971
2844
2843
2842
2841
2840
2839
2838
2837
2836
2835
2834
2833
2832
2831
2830
2829
2828
2827
2826
2825
2824
2823
2822
2821
2820
2819
4277
4276
4275
4274
4273
4272
4271
4...

result:

ok q=100000

Test #149:

score: 0
Accepted
time: 291ms
memory: 11696kb

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: 329ms
memory: 11388kb

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: 222ms
memory: 11268kb

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:

3746
3745
3744
3743
3742
3741
3740
3739
3738
3737
3736
7485
4993
7484
4992
2498
2497
4991
4990
2496
1249
1248
1247
1246
1245
1244
1243
1242
1241
1240
1239
1238
1237
2495
2494
2493
1236
1235
1234
1233
1232
1231
1230
1229
1228
1227
1226
1225
1224
4989
1223
1222
1221
1220
1219
1218
1217
1216
1215
2492
...

result:

ok q=100000

Test #152:

score: 0
Accepted
time: 231ms
memory: 11720kb

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
4993
4992
7486
7485
7484
1249
1248
7483
7482
7481
7480
7479
7478
3745
3744
3743
3742
7477
7476
7475
7474
1247
1246
1245
1244
1243
1242
1241
1240
1239
1238
1237
1236
1235
1234
1233
1232
1231
4991
6240
6239
6238
3741
3740
3739
3738
4990
1230
1229
1228
1227
1226
1225
1224
1223
1222
1221
1220
1219
1...

result:

ok q=100000

Test #153:

score: 0
Accepted
time: 834ms
memory: 11108kb

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:

99999

result:

ok q=100000

Test #154:

score: 0
Accepted
time: 733ms
memory: 11040kb

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:

10878
10877
10876
10875
8572
8571
8570
8569
8568
8567
8566
1351
1350
1349
1348
1347
1346
1344
780
186
185
184
779
778
777
774
773
772
771
768
767
766
765
99950
99949
99948
99946
99926
99923
99922
99921
99920
99906
99895
99893
99892
99891
99888
99883
99882
99880
99877
99850
99848
99840
99831
99830
99...

result:

ok q=100000

Test #155:

score: 0
Accepted
time: 635ms
memory: 11092kb

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
53573
53572
53571
53569
53568
53567
12224
12223
12222
12221
12220
12219
12218
12217
12216
12215
12214
12213
12212
12211
12210
8352
8351
8349
8348
8346
8344
8343
8342
8341
8340
8339
8338
8337
7204
7203
1575
1574
1573
1572
1571
1570
1569
1568
1566
1565
1564
1563
1562
1561
1559
1558
1557
15...

result:

ok q=100000

Test #156:

score: 0
Accepted
time: 539ms
memory: 11040kb

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
63816
63815
19499
19498
1531
1530
1529
1528
1527
1526
1525
1524
1523
1522
1520
1519
1518
1517
1515
1514
1513
1512
1510
1509
1508
1507
1506
1505
1504
1503
1502
1501
1500
1499
1497
1496
1495
1494
1493
1492
1491
1490
1489
1488
1487
1486
1485
1484
1483
1482
1481
1480
1479
1478
1477
1476
14...

result:

ok q=100000

Test #157:

score: 0
Accepted
time: 453ms
memory: 11080kb

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:

65646
65645
61455
61454
61453
61452
31721
31719
31718
31717
31715
31714
31713
31712
31711
31710
31709
31707
31706
31705
31704
30022
30021
30020
30019
30018
30016
30015
30014
30013
30012
30008
30007
30006
30005
30004
30003
30002
30000
29998
29997
15524
15523
15522
15520
15519
15518
15517
15516
15515
...

result:

ok q=100000

Test #158:

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

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
93526
93525
93524
93523
74698
74697
74696
74695
74694
74693
74692
74691
71872
71871
71870
71869
71867
71866
58609
58608
58607
58606
58605
58604
58603
58602
58601
58600
58599
58598
58597
58596
14368
14367
14366
14365
14364
14363
14362
14361
14360
14359
14357
14356
14355
14354
14...

result:

ok q=100000

Test #159:

score: 0
Accepted
time: 228ms
memory: 11304kb

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: 841ms
memory: 11120kb

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:

100000

result:

ok q=100000

Test #161:

score: 0
Accepted
time: 734ms
memory: 11112kb

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:

99997
99995
99992
99966
99963
99958
99956
99953
99948
99943
99934
99933
99932
99930
99928
99926
99921
99917
99913
99897
99896
99883
100000
99990
99987
99986
99977
99976
99975
99971
99954
99949
99942
99937
99936
99924
99918
99914
99906
99893
99881
99876
99875
99848
99847
99845
99844
99843
99839
99838...

result:

ok q=100000

Test #162:

score: 0
Accepted
time: 633ms
memory: 11080kb

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:

100000
99995
99985
99982
99976
99975
99968
99962
99957
99954
99951
99942
99939
99938
99931
99930
99928
99926
99918
99917
99902
99900
99898
99894
99892
99885
99871
99855
99854
99849
99846
99843
99839
99836
99828
99825
99809
99807
99805
99803
99787
99785
99771
99762
99761
99754
99745
99741
99732
99729...

result:

ok q=100000

Test #163:

score: 0
Accepted
time: 543ms
memory: 11104kb

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:

99997
99996
99995
99993
99991
99984
99976
99974
99973
99972
99970
99969
99967
99964
99961
99960
99959
99958
99957
99956
99955
99954
99946
99945
99943
99942
99936
99935
99934
99924
99921
99920
99910
99909
99908
99904
99897
99896
99893
99892
99884
99883
99877
99876
99873
99871
99869
99866
99862
99860
...

result:

ok q=100000

Test #164:

score: 0
Accepted
time: 454ms
memory: 11136kb

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:

99995
99992
99989
99987
99985
99983
99981
99980
99977
99975
99961
99958
99957
99944
99938
99937
99931
99930
99929
99926
99924
99921
99919
99918
99915
99914
99911
99910
99904
99901
99896
99895
99894
99893
99889
99888
99886
99885
99880
99878
99874
99873
99869
99865
99863
99862
99859
99858
99856
99855
...

result:

ok q=100000

Test #165:

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

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:

99999
99998
99995
99994
99991
99988
99986
99984
99982
99971
99970
99968
99962
99960
99959
99955
99954
99953
99951
99949
99944
99943
99935
99934
99933
99932
99927
99926
99925
99924
99922
99921
99919
99918
99916
99909
99901
99900
99898
99897
99895
99894
99889
99888
99878
99871
99868
99862
99858
99846
...

result:

ok q=100000

Test #166:

score: 0
Accepted
time: 293ms
memory: 11744kb

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:

99989
99988
99986
99985
99982
99981
99977
99965
99964
99960
99958
99957
99953
99949
99943
99940
99936
99933
99932
99931
99930
99928
99915
99913
99912
99911
99909
99900
99899
99897
99889
99885
99883
99881
99879
99878
99872
99868
99867
99866
99864
99859
99858
99855
99854
99846
99843
99842
99817
99815
...

result:

ok q=100000

Test #167:

score: 0
Accepted
time: 832ms
memory: 11092kb

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:

99989

result:

ok q=100000

Test #168:

score: 0
Accepted
time: 739ms
memory: 11060kb

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
21634
21633
21632
21631
21628
21627
21626
21622
21621
21620
13397
13396
3382
3381
3380
834
833
832
831
829
826
825
824
822
820
819
818
816
815
814
813
812
811
809
808
807
805
804
803
802
801
800
99988
99967
99956
99955
99953
99950
99946
99945
99936
99935
99934
99933
99931
99924
99921
99915
999...

result:

ok q=100000

Test #169:

score: 0
Accepted
time: 640ms
memory: 11136kb

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
10059
10058
10057
10056
10054
3814
3813
3812
3811
3810
3809
3808
3807
3806
3804
3803
3802
3801
3800
3799
3798
3797
3796
3794
3793
3791
3790
3788
3785
3784
3783
3782
3781
3780
3779
3778
3777
3776
3775
3774
3773
3772
3770
3767
3766
3765
3764
3763
3762
3761
3760
3408
3407
3405
3404
3402
3401
3400
3...

result:

ok q=100000

Test #170:

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

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
17772
17771
4213
4212
4211
4210
4209
4206
4205
4204
4203
4202
4201
4200
4199
4198
4197
4196
4195
4194
4193
4191
4190
4189
4188
4187
4186
4185
4184
4183
4181
4180
4003
4002
4000
3999
3998
3997
3996
3995
3994
3993
3992
3990
3989
3988
3987
3986
3985
3984
3982
3981
3980
3979
3978
3977
3976
3975
3974
3...

result:

ok q=100000

Test #171:

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

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
44447
28873
28871
28870
27341
27340
27339
27338
27337
27336
9679
9678
9677
9676
9675
9674
9672
9671
9670
9669
9668
9667
9666
9665
9664
9663
9662
9661
9659
9658
9657
9656
9655
9654
9653
9652
9651
9650
9649
2547
2546
2545
2544
2543
2542
2541
2540
2539
2538
2537
2535
2534
2533
2532
2531...

result:

ok q=100000

Test #172:

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

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
97490
97489
97488
67701
67700
67699
67697
67695
67694
67693
67692
67691
67690
67688
67687
67686
67685
66656
66655
66653
10755
10754
10753
10751
10749
10748
10747
10746
10745
10744
10743
10742
10741
10740
10739
10738
10737
10736
10735
10734
10733
10732
10731
10730
10729
10728
10727
10...

result:

ok q=100000

Test #173:

score: 0
Accepted
time: 231ms
memory: 11324kb

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: 368ms
memory: 11404kb

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: 436ms
memory: 11484kb

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: 217ms
memory: 10772kb

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:

969
0
968
0
967
0
966
0
965
0
964
0
963
0
962
0
961
0
960
0
959
0
958
0
957
0
956
0
955
0
954
0
953
0
952
0
951
0
950
0
949
0
948
0
947
0
946
0
945
0
944
0
943
0
942
0
941
0
940
0
939
0
938
0
937
0
936
0
935
0
934
0
933
0
932
0
931
0
930
0
929
0
928
0
927
0
926
0
925
0
924
0
923
0
922
0
921
0
920
0
...

result:

ok q=100000

Test #177:

score: 0
Accepted
time: 219ms
memory: 11040kb

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
969
0
968
967
0
0
966
965
964
0
0
963
962
0
961
0
0
960
959
958
957
0
0
956
0
955
0
0
0
0
0
0
954
0
953
952
0
951
950
0
0
949
948
947
946
945
944
0
0
0
0
943
942
941
0
940
939
938
0
937
936
0
0
0
935
934
0
933
0
932
0
931
930
0
929
928
927
0
926
925
924
923
922
921
0
920
0
0
0
0
919
918
917
0
0
91...

result:

ok q=100000

Test #178:

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

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: 402ms
memory: 11052kb

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: 218ms
memory: 10872kb

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
484
0
483
482
481
480
479
0
965
478
477
476
964
475
474
473
472
471
470
0
963
0
469
0
962
468
467
466
961
0
465
464
463
462
960
461
959
0
460
459
458
0
958
457
456
455
957
0
454
453
452
451
956
450
449
0
448
0
955
447
954
0
953
0
446
0
445
444
443
442
441
440
952
0
439
438
...

result:

ok q=100000

Test #181:

score: 0
Accepted
time: 219ms
memory: 11136kb

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
482
481
480
479
478
477
476
475
474
473
0
0
0
0
969
968
0
0
472
0
471
0
967
470
469
468
966
0
467
466
465
965
0
464
463
462
461
460
964
963
962
0
0
0
459
0
458
457
0
0
456
0
0
0
0
0
961
455
454
0
0
0
960
0
0
0
0
959
958
957
956
955
954
953
952
0
0
453
0
951
452
950
949
0
0
948
947
946
...

result:

ok q=100000

Test #182:

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

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: 378ms
memory: 11052kb

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: 223ms
memory: 10796kb

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
617
0
208
207
206
205
408
204
407
406
203
405
616
0
202
201
200
199
198
197
196
195
194
193
192
0
191
0
190
189
188
0
187
186
185
184
615
0
404
0
403
0
402
183
182
181
180
179
401
178
400
177
176
0
399
398
175
174
173
397
614
172
171
170
169
0
168
167
166
396
395
0
165
164
...

result:

ok q=100000

Test #185:

score: 0
Accepted
time: 212ms
memory: 11044kb

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
206
205
204
611
610
0
0
0
203
202
201
609
608
405
404
403
0
0
200
199
198
402
401
400
399
398
397
396
395
394
393
392
391
607
0
390
389
388
387
386
385
606
197
196
195
194
193
384
383
382
381
380
0
192
191
190
189
188
187
186
379
185
184
183
378
377
376
60...

result:

ok q=100000

Test #186:

score: 0
Accepted
time: 322ms
memory: 11140kb

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: 358ms
memory: 11216kb

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: 222ms
memory: 10876kb

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
209
208
207
206
420
626
0
625
624
834
419
833
205
204
203
202
0
832
201
200
418
199
198
417
197
416
196
415
414
413
412
623
622
411
621
195
620
410
409
194
193
192
191
190
189
619
408
618
188
187
186
185
184
183
0
182
181
407
0
406
405
404
617
831
403
402
401
400
616
615
180
179
178
...

result:

ok q=100000

Test #189:

score: 0
Accepted
time: 219ms
memory: 11216kb

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
206
626
831
830
205
204
203
202
201
200
199
198
197
196
625
195
194
193
192
624
623
622
191
190
189
188
187
621
620
829
828
619
618
827
826
617
423
422
421
420
616
825
419
418
417
416
415
615
614
613
612
611
610
609
608
414
413
412
411
410
409
408
407
406
405
404
403
402
824
401
400
...

result:

ok q=100000

Test #190:

score: 0
Accepted
time: 299ms
memory: 10612kb

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: 323ms
memory: 10608kb

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: 209ms
memory: 10604kb

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
583
196
195
194
193
391
390
389
192
388
387
386
191
385
190
189
188
384
187
186
185
184
183
182
181
180
179
777
582
178
177
176
175
174
173
172
171
383
382
170
169
168
167
166
165
164
163
162
161
160
159
381
380
158
157
379
378
776
970
0
377
376
375
0
156
155
969
374
373
372
371
581
580
579
...

result:

ok q=100000

Test #193:

score: 0
Accepted
time: 209ms
memory: 10932kb

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
188
388
387
386
385
384
383
0
0
0
0
584
583
582
581
580
579
578
382
577
777
776
0
0
187
186
185
184
183
182
181
180
179
178
177
176
175
174
173
381
970
969
968
967
966
172
171
170
169
380
576
575
574
573
379
378
377
376
375
374
373
168
167
166
165
164
163
162
161
372
371
...

result:

ok q=100000

Test #194:

score: 0
Accepted
time: 263ms
memory: 9896kb

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: 280ms
memory: 9812kb

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
326
164
327
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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: 170ms
memory: 9496kb

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
485
484
483
325
324
323
322
321
807
482
806
0
647
646
163
645
481
644
966
320
319
805
480
162
161
160
318
317
479
478
965
159
158
157
316
315
314
477
156
155
313
312
311
310
309
308
307
154
306
804
153
152
151
150
149
148
147
803
964
802
146
801
643
305
304
303
642
145
144
143
142
141
140
13...

result:

ok q=100000

Test #197:

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

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
158
157
319
318
317
316
156
155
154
153
152
151
150
149
148
147
146
145
144
481
480
479
478
802
801
0
0
643
642
641
640
639
638
315
314
143
142
141
140
139
313
312
311
310
309
308
307
477
476
475
138
137
136
135
134
133
132
131
130
129
128
127
126
125
124
123
122
121
120
119
118
117
116
115
...

result:

ok q=100000

Test #198:

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

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
140
557
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: 247ms
memory: 8980kb

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: 146ms
memory: 8804kb

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
416
415
414
413
412
139
138
137
136
135
134
695
694
557
277
556
411
276
410
409
555
275
554
408
553
552
551
133
132
131
130
129
128
127
126
125
124
123
122
121
120
119
118
117
116
115
114
113
112
969
111
968
274
110
109
108
107
106
105
407
832
967
693
550
549
548
104
103
547
406
405
404
403
402
...

result:

ok q=100000

Test #201:

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

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
415
141
140
139
138
137
136
135
134
133
132
131
130
129
128
127
126
125
124
123
122
121
120
280
119
118
117
116
115
114
113
112
279
278
277
276
275
111
110
109
108
107
106
105
104
103
274
273
272
271
270
269
268
267
102
266
265
264
263
262
261
260
259
258
257
256
255
101
100
99
98
254
253
414
...

result:

ok q=100000

Test #202:

score: 0
Accepted
time: 191ms
memory: 8552kb

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: 207ms
memory: 8556kb

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

result:

ok q=100000

Test #204:

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

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
125
124
369
368
367
366
365
364
248
247
246
245
244
363
362
361
360
611
610
491
490
123
122
121
120
119
118
117
243
242
241
240
116
115
114
239
238
113
112
111
237
110
109
108
107
106
236
235
234
359
233
105
104
103
232
231
230
229
228
227
226
358
609
608
102
101
100
99
98
97
96
95
225
224
94
93...

result:

ok q=100000

Test #205:

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

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
611
374
373
372
371
370
369
368
367
366
365
364
363
362
361
360
851
850
849
848
847
846
731
845
844
843
125
124
123
122
121
120
119
118
117
116
115
114
113
112
111
110
109
108
107
106
105
104
103
102
101
100
99
250
98
97
96
95
94
93
92
...

result:

ok q=100000

Extra Test:

score: 0
Extra Test Passed