QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#20635#2603. Disbalancewlxhkk#AC ✓98ms35096kbC++14763b2022-02-16 21:48:082022-05-03 10:52:12

詳細信息

Test #1:

score: 100
Accepted
time: 17ms
memory: 35036kb

input:

8
1 1
1 2
2 1
2 2
3 1
3 2
3 3
4 3

output:

2
5
1
332748120
0
499122177
299473307
598946612

result:

ok 8 numbers

Test #2:

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

input:

20
9 12
2 6
9 14
3 7
1 2
1 2
10 11
6 7
10 13
7 4
1 3
4 4
2 2
1 5
10 9
6 10
7 5
7 4
10 7
4 3

output:

601023541
104577993
588440629
323241035
5
5
537116365
615800088
583321633
0
9
570425345
332748120
20
334869712
974144215
0
0
0
598946612

result:

ok 20 numbers

Test #3:

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

input:

20
7 12
8 12
1 1
1 6
2 11
5 4
6 13
7 13
6 8
1 5
7 13
2 8
3 10
8 9
5 3
1 2
5 6
10 8
4 3
3 3

output:

269558826
522207092
2
27
245743886
926941185
375649298
628061442
401724376
20
628061442
880990276
368615785
683801260
0
5
126761188
0
598946612
299473307

result:

ok 20 numbers

Test #4:

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

input:

20
1 5
2 5
10 12
10 12
3 3
9 11
6 7
1 8
8 8
1 3
9 5
9 9
3 6
2 4
10 13
10 9
3 9
5 7
7 6
6 8

output:

20
532396998
374710197
374710197
299473307
973433586
615800088
44
278918935
9
0
347599278
655989151
532396995
583321633
334869712
867737959
671258108
688183607
401724376

result:

ok 20 numbers

Test #5:

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

input:

20
2 6
8 10
7 4
3 5
9 9
10 6
2 4
9 13
4 3
8 14
10 13
3 11
5 10
2 11
4 9
5 7
6 8
1 6
8 9
6 13

output:

104577993
760178656
0
156866973
347599278
0
532396995
543627802
598946612
180187355
583321633
522191842
831814893
245743886
907494870
671258108
401724376
27
683801260
375649298

result:

ok 20 numbers

Test #6:

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

input:

20
1 2
4 5
5 10
8 11
5 11
8 14
6 9
8 7
4 12
9 9
7 5
7 8
3 6
10 15
1 8
2 4
4 6
3 2
8 6
4 6

output:

5
142606337
831814893
900203882
627046821
180187355
485493133
134960775
7
347599278
0
877826765
655989151
295767061
44
532396995
332748119
499122177
0
332748119

result:

ok 20 numbers

Test #7:

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

input:

20
6 6
2 8
4 10
8 14
9 6
9 6
9 12
3 2
7 6
4 11
7 4
6 5
9 13
4 10
1 9
2 2
7 7
6 10
7 11
6 4

output:

101552997
880990276
691092249
180187355
0
0
601023541
499122177
688183607
614304223
0
308980395
543627802
691092249
54
332748120
661424143
974144215
328279082
0

result:

ok 20 numbers

Test #8:

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

input:

20
4 11
2 11
8 11
7 9
3 3
9 14
4 11
8 14
3 5
1 6
8 12
8 8
3 11
1 5
3 11
3 9
6 4
6 7
6 13
3 9

output:

614304223
245743886
900203882
176961499
299473307
588440629
614304223
180187355
156866973
27
522207092
278918935
522191842
20
522191842
867737959
0
615800088
375649298
867737959

result:

ok 20 numbers

Test #9:

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

input:

20
1 9
5 10
3 10
8 13
4 4
9 9
2 4
7 9
5 12
2 3
4 3
9 7
7 7
1 3
5 8
3 2
9 13
1 1
7 12
6 6

output:

54
831814893
368615785
448034137
570425345
347599278
532396995
176961499
127924645
332748122
598946612
0
661424143
9
489759135
499122177
543627802
2
269558826
101552997

result:

ok 20 numbers

Test #10:

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

input:

20
8 10
3 9
3 7
8 7
2 7
7 7
2 2
7 7
5 3
7 6
9 14
3 2
10 15
5 7
10 10
5 8
5 3
9 14
4 3
10 9

output:

760178656
867737959
323241035
134960775
104577997
661424143
332748120
661424143
0
688183607
588440629
499122177
295767061
671258108
56894028
489759135
0
588440629
598946612
334869712

result:

ok 20 numbers

Test #11:

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

input:

20
2 11
1 8
4 10
2 2
8 12
3 2
6 8
5 8
9 10
9 6
9 7
9 14
3 5
2 9
1 2
6 10
1 6
4 3
4 7
1 7

output:

245743886
44
691092249
332748120
522207092
499122177
401724376
489759135
38188698
0
0
588440629
156866973
880990281
5
974144215
27
598946612
2
35

result:

ok 20 numbers

Test #12:

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

input:

20
4 6
3 9
4 9
10 9
9 5
5 6
3 7
10 7
3 9
9 13
3 11
3 6
8 13
8 6
9 11
10 11
3 11
8 5
9 5
3 4

output:

332748119
867737959
907494870
334869712
0
126761188
323241035
0
867737959
543627802
522191842
655989151
448034137
0
973433586
537116365
522191842
0
0
299473308

result:

ok 20 numbers

Test #13:

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

input:

20
9 7
5 9
9 11
7 13
5 11
8 11
1 7
5 9
3 11
6 6
4 6
9 13
7 13
6 11
2 6
6 13
6 8
5 7
2 6
5 11

output:

0
524662784
973433586
628061442
627046821
900203882
35
524662784
522191842
101552997
332748119
543627802
628061442
897356188
104577993
375649298
401724376
671258108
104577993
627046821

result:

ok 20 numbers

Test #14:

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

input:

20
6 12
5 7
10 13
3 6
3 4
3 5
7 9
1 2
4 5
2 4
4 9
10 6
3 10
5 11
8 6
3 3
2 4
6 13
2 6
8 8

output:

581170194
671258108
583321633
655989151
299473308
156866973
176961499
5
142606337
532396995
907494870
0
368615785
627046821
0
299473307
532396995
375649298
104577993
278918935

result:

ok 20 numbers

Test #15:

score: 0
Accepted
time: 82ms
memory: 35024kb

input:

300000
1 5
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 5
1 6
1 6
1 6
1 6
1 5
1 6
1 6
1 5
1 6
1 6
1 6
1 6
1 6
1 5
1 6
1 6
1 6
1 5
1 6
1 5
1 6
1 6
1 6
1 6
1 5
1 5
1 5
1 5
1 6
1 6
1 6
1 5
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 5
1 6
1 5
1 6
1 6
1 6
1 6
1 5
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 5
1 6
1 6
1 6
1 6
1 5
1 6
1 5
1...

output:

20
27
27
27
27
27
27
27
20
27
27
27
27
20
27
27
20
27
27
27
27
27
20
27
27
27
20
27
20
27
27
27
27
20
20
20
20
27
27
27
20
27
27
27
27
27
27
27
27
27
20
27
20
27
27
27
27
20
27
27
27
27
27
27
27
20
27
27
27
27
20
27
20
27
20
27
20
20
27
20
20
27
27
27
27
27
20
20
20
27
20
27
27
20
20
27
20
27
27
27
...

result:

ok 300000 numbers

Test #16:

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

input:

300000
6 1
5 1
6 1
6 1
6 1
6 1
6 1
5 1
6 1
5 1
6 1
6 1
6 1
6 1
5 1
6 1
6 1
5 1
6 1
6 1
6 1
5 1
5 1
6 1
6 1
5 1
6 1
5 1
5 1
5 1
6 1
6 1
5 1
5 1
5 1
6 1
5 1
5 1
5 1
6 1
6 1
5 1
6 1
5 1
6 1
5 1
5 1
6 1
6 1
6 1
6 1
6 1
6 1
6 1
6 1
6 1
6 1
6 1
5 1
5 1
6 1
6 1
5 1
6 1
5 1
5 1
6 1
5 1
6 1
5 1
6 1
6 1
6 1
5...

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 300000 numbers

Test #17:

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

input:

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

output:

299473307
532396998
27
0
27
27
0
0
27
532396998
0
0
532396998
27
27
20
299473308
598946612
27
0
598946612
20
0
0
27
598946612
0
27
0
532396998
27
598946612
532396995
532396998
0
598946612
532396998
532396998
27
598946612
27
532396995
299473307
299473308
532396995
598946612
299473307
598946612
27
0
0...

result:

ok 300000 numbers

Test #18:

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

input:

1
1000000 1000000

output:

509847430

result:

ok 1 number(s): "509847430"

Test #19:

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

input:

2
1 1000000
1 999998

output:

879323500
877323499

result:

ok 2 number(s): "879323500 877323499"

Test #20:

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

input:

2
1000000 1
999998 1

output:

0
0

result:

ok 2 number(s): "0 0"

Test #21:

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

input:

2
2 1000000
2 999996

output:

582652557
561022556

result:

ok 2 number(s): "582652557 561022556"

Test #22:

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

input:

300000
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 300000 numbers

Test #23:

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

input:

300000
2 3
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 1
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 1
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 3
2 3
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 3
2 2
2...

output:

332748122
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
1
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
33274812...

result:

ok 300000 numbers

Test #24:

score: 0
Accepted
time: 98ms
memory: 35096kb

input:

300000
2 3
2 5
2 3
2 4
2 4
2 4
2 4
2 5
2 4
2 3
2 4
2 5
2 4
2 5
2 3
2 5
2 4
2 4
2 4
2 3
2 4
2 4
2 4
2 4
2 6
2 4
2 4
2 3
2 4
2 3
2 5
2 2
2 4
2 4
2 3
2 5
2 3
2 4
2 2
2 4
2 5
2 4
2 4
2 5
2 4
2 5
2 4
2 3
2 3
2 4
2 4
2 4
2 4
2 4
2 3
2 6
2 4
2 5
2 5
2 4
2 4
2 2
2 3
2 3
2 5
2 4
2 4
2 4
2 3
2 5
2 4
2 4
2 3
2...

output:

332748122
532396998
332748122
532396995
532396995
532396995
532396995
532396998
532396995
332748122
532396995
532396998
532396995
532396998
332748122
532396998
532396995
532396995
532396995
332748122
532396995
532396995
532396995
532396995
104577993
532396995
532396995
332748122
532396995
332748122
...

result:

ok 300000 numbers

Test #25:

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

input:

153887
2 8
2 13
2 15
2 6
2 11
2 12
2 6
2 13
2 11
2 7
2 13
2 10
2 13
2 4
2 12
2 10
2 11
2 10
2 11
2 13
2 8
2 14
2 6
2 15
2 11
2 10
2 7
2 10
2 9
2 6
2 11
2 9
2 8
2 11
2 12
2 9
2 7
2 7
2 16
2 5
2 11
2 10
2 8
2 15
2 12
2 9
2 13
2 11
2 6
2 10
2 10
2 11
2 10
2 11
2 12
2 9
2 12
2 16
2 8
2 8
2 10
2 11
2 10
...

output:

880990276
15379818
81929457
104577993
245743886
15379811
104577993
15379818
245743886
104577997
15379818
245743880
15379818
532396995
15379811
245743880
245743886
245743880
245743886
15379818
880990276
81929449
104577993
81929457
245743886
245743880
104577997
245743880
880990281
104577993
245743886
...

result:

ok 153887 numbers

Test #26:

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

input:

71536
2 43
2 25
2 25
2 31
2 17
2 34
2 21
2 32
2 29
2 21
2 35
2 23
2 33
2 33
2 38
2 25
2 29
2 21
2 17
2 11
2 21
2 34
2 24
2 32
2 27
2 23
2 24
2 20
2 27
2 27
2 26
2 31
2 22
2 23
2 26
2 29
2 20
2 19
2 21
2 34
2 24
2 31
2 21
2 22
2 37
2 22
2 28
2 26
2 28
2 18
2 23
2 43
2 27
2 27
2 21
2 26
2 23
2 21
2 33...

output:

698462140
978912733
978912733
932358518
610411779
368847471
748014425
55113497
996761348
748014425
368847489
140387451
55113514
55113514
4277363
978912733
996761348
748014425
610411779
245743886
748014425
368847471
978912720
55113497
239472499
140387451
978912720
748014414
239472499
239472499
239472...

result:

ok 71536 numbers

Test #27:

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

input:

19420
2 132
2 80
2 89
2 95
2 107
2 148
2 78
2 52
2 100
2 98
2 103
2 86
2 126
2 94
2 92
2 151
2 78
2 85
2 95
2 130
2 98
2 96
2 130
2 81
2 116
2 81
2 91
2 134
2 68
2 161
2 102
2 108
2 158
2 146
2 84
2 93
2 68
2 108
2 78
2 101
2 104
2 128
2 63
2 98
2 121
2 71
2 112
2 71
2 93
2 115
2 80
2 112
2 128
2 88...

output:

806628244
505922480
837346202
373164131
301110762
139466844
419654369
539656672
284331301
729093536
264948070
534507894
718547795
373164083
782969565
476622448
419654369
282078244
373164131
671527372
729093536
23264097
671527372
505922521
836212739
505922521
804437139
259442585
500655295
261164008
2...

result:

ok 19420 numbers

Test #28:

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

input:

1994
2 887
2 1027
2 1036
2 1163
2 743
2 1137
2 586
2 1250
2 1367
2 1075
2 863
2 1171
2 794
2 658
2 626
2 1070
2 1062
2 1096
2 488
2 817
2 985
2 1387
2 778
2 1141
2 1366
2 1321
2 858
2 1262
2 916
2 722
2 1329
2 596
2 1046
2 496
2 411
2 723
2 462
2 529
2 1287
2 1270
2 1152
2 934
2 747
2 1056
2 1502
2 ...

output:

40439081
653529991
33404870
968745880
480561185
4459186
34760875
655967895
461523106
427285734
996140503
419843412
435743133
782055849
36084821
429980574
697577378
256124665
9142997
347496863
950833241
734665504
906290627
807789934
461522422
589956165
597738303
887568637
610100256
941945222
92651095...

result:

ok 1994 numbers

Test #29:

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

input:

203
2 8464
2 7381
2 8715
2 8761
2 8216
2 13057
2 10722
2 10297
2 11228
2 6462
2 8334
2 9701
2 10088
2 13287
2 7017
2 7459
2 9828
2 13720
2 6661
2 6373
2 8085
2 9086
2 11126
2 12107
2 7862
2 12412
2 9834
2 11664
2 12130
2 6354
2 8649
2 13276
2 6432
2 8282
2 9229
2 12305
2 6460
2 8755
2 7460
2 10064
2...

output:

618684985
879657097
294382910
793805500
928230403
812630376
782745031
270485302
613169604
216189742
233791425
261706743
780171635
634206274
680733011
40468716
539601073
988644033
334421517
990651624
42855911
663302187
967787749
579186985
365030087
793661384
156024995
118400264
110463956
767081577
25...

result:

ok 203 numbers

Test #30:

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

input:

62
2 30164
2 43329
2 41925
2 30283
2 41939
2 21603
2 31751
2 36914
2 31850
2 26752
2 31561
2 32690
2 49044
2 8973
2 31902
2 27432
2 39480
2 31177
2 40417
2 35692
2 35640
2 36943
2 34073
2 19103
2 25565
2 24739
2 24067
2 33367
2 30967
2 24174
2 37583
2 26358
2 31756
2 51908
2 16288
2 44492
2 31301
2 ...

output:

800611388
297488961
613227043
342395913
443464809
660855972
692528454
233557123
666382878
407464268
77353322
98967625
90093245
772517227
737080406
360168386
402177447
55840971
153648416
400687235
143560712
209449108
886868865
664354091
974560821
650596625
965858012
121523797
696060526
904320082
3428...

result:

ok 62 numbers

Test #31:

score: 0
Accepted
time: 79ms
memory: 35028kb

input:

300000
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
3 2
2 1
2 1
2 1
2 1
2 1
2 1
3 2
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
3 2
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
499122177
1
1
1
1
1
1
499122177
1
1
1
1
1
1
1
1
499122177
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 300000 numbers

Test #32:

score: 0
Accepted
time: 96ms
memory: 35012kb

input:

300000
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
3 3
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 1
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 3
2 2
2 2
2 2
3 3
2 2
2 2
2 2
2 2
2...

output:

332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
332748120
...

result:

ok 300000 numbers

Test #33:

score: 0
Accepted
time: 80ms
memory: 35024kb

input:

300000
2 3
2 5
2 5
2 3
2 5
2 4
2 5
2 4
2 3
2 4
2 3
2 4
2 4
2 3
2 4
2 4
2 3
2 5
3 5
2 4
2 4
2 5
2 4
2 2
2 5
2 4
2 4
2 4
2 5
2 3
2 6
2 5
2 3
2 4
2 4
2 5
2 6
2 4
2 4
2 3
2 4
2 4
2 5
2 4
2 4
2 4
2 5
2 3
2 3
2 5
2 4
2 3
2 4
2 5
2 3
2 3
2 4
2 5
2 4
2 3
2 5
2 4
2 4
2 4
2 2
2 3
2 4
2 5
2 5
2 5
2 5
2 3
2 4
2...

output:

332748122
532396998
532396998
332748122
532396998
532396995
532396998
532396995
332748122
532396995
332748122
532396995
532396995
332748122
532396995
532396995
332748122
532396998
156866973
532396995
532396995
532396998
532396995
332748120
532396998
532396995
532396995
532396995
532396998
332748122
...

result:

ok 300000 numbers

Test #34:

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

input:

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

output:

245743886
81929449
245743880
81929449
15379811
245743886
245743886
880990281
245743886
104577997
245743886
15379818
15379818
15379811
104577997
15379811
880990281
880990276
104577993
880990281
245743880
880990281
15379811
245743880
532396998
15379811
245743880
880990276
245743880
610411779
880990276...

result:

ok 153305 numbers

Test #35:

score: 0
Accepted
time: 41ms
memory: 35012kb

input:

71345
2 18
2 30
2 28
2 27
2 34
2 26
2 14
2 27
2 28
2 21
2 18
2 22
2 12
2 14
2 31
2 24
2 36
2 32
2 22
2 32
2 13
2 32
2 31
2 30
2 16
2 24
2 27
2 27
2 16
2 20
2 36
2 25
2 20
2 26
3 25
2 25
2 30
2 25
2 30
2 32
2 19
3 24
2 28
2 17
2 30
2 24
2 13
2 29
2 20
2 33
2 22
2 36
2 23
2 21
2 34
2 29
2 21
2 26
2 11...

output:

557872612
932358502
996761333
239472499
368847471
239472485
81929449
239472499
996761333
748014425
557872612
140387439
15379811
81929449
932358518
978912720
746561587
55113497
140387439
55113497
15379818
55113497
932358518
932358502
610411770
978912720
239472499
239472499
610411770
748014414
7465615...

result:

ok 71345 numbers

Test #36:

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

input:

19371
2 79
2 125
2 119
2 81
2 148
2 105
2 101
2 92
2 107
2 78
2 120
2 109
2 95
2 123
2 154
2 122
2 75
2 165
2 111
2 124
2 133
2 115
2 86
2 86
2 127
2 88
2 48
2 87
2 106
2 152
2 82
2 93
2 92
2 123
2 112
2 113
2 66
2 79
2 123
2 111
2 93
2 100
2 106
2 129
2 129
2 85
2 187
2 41
2 102
2 110
2 76
2 47
2 1...

output:

419654409
380559486
341285045
505922521
139466844
702274273
284331352
782969565
301110762
419654369
828032352
987976252
373164131
811800921
344996700
811800859
569973474
483788231
781132939
380559423
806628311
85396415
534507894
534507894
718547859
837346157
112365146
534507938
301110708
757174859
9...

result:

ok 19371 numbers

Test #37:

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

input:

1987
2 1253
2 507
2 887
2 683
2 912
2 872
2 1229
2 841
2 1317
2 1126
2 996
2 590
2 1221
2 529
2 1177
2 1686
2 1176
2 1049
2 816
2 786
3 845
2 428
3 816
2 1522
2 1415
2 1015
2 642
2 621
2 1148
2 802
2 892
2 1021
2 1070
2 1202
2 1024
2 1379
2 1034
2 974
2 1051
2 783
2 825
2 978
2 1235
2 833
2 709
2 91...

output:

291088758
252478756
40439081
420269945
654996251
799747537
358752884
178006723
545393438
424420155
781979021
331761393
78733797
800271362
289809170
119039922
289808581
848732379
347496454
543756995
167986557
987726725
521077401
873260806
978808227
39945686
625496401
676150559
906548193
410938964
832...

result:

ok 1987 numbers

Test #38:

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

input:

199
2 7927
2 7579
2 10919
2 9230
2 7731
2 7441
2 10233
2 11583
2 8279
2 11680
2 12614
2 7403
2 7939
2 11179
2 13001
2 10005
2 13833
2 13212
2 10341
2 11263
2 11998
2 7408
2 8998
2 9979
2 8354
2 11766
2 12187
2 8745
2 10776
2 10514
2 12831
2 13958
2 14514
2 12781
2 14293
2 12921
2 11243
2 13446
2 125...

output:

701556503
617553038
551708964
270900556
756399766
889827239
267272093
201101004
138682633
401401556
612267080
901524477
437469910
126739474
625814726
515666717
992828117
941661306
516701635
947090152
187617471
685187160
875263103
584409636
725562579
86838126
959903796
434636009
538174011
425965298
2...

result:

ok 199 numbers

Test #39:

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

input:

63
2 32447
2 31323
2 46167
2 29988
2 17931
2 21237
2 39066
2 34530
2 20452
2 29531
2 39425
2 21703
2 21048
2 23251
2 25451
2 41831
2 26843
2 23637
2 30461
2 41842
2 33527
2 31421
2 28236
2 32172
2 29713
2 32839
2 38922
2 23844
2 42726
2 25725
2 24702
2 15549
2 44478
2 45491
2 41639
2 25696
2 21234
2...

output:

643925240
356891056
281808578
926087052
264364849
637404052
26555270
871928563
30993286
857921559
554736468
172977457
892121323
896262915
664327817
426380062
837539894
613514821
884422824
342104230
500335132
142192077
798791986
690801593
429601492
291557633
669087590
547111683
567091807
603043701
32...

result:

ok 63 numbers

Test #40:

score: 0
Accepted
time: 81ms
memory: 35024kb

input:

222358
5 4
4 3
5 4
4 3
5 4
4 3
4 3
5 4
5 4
6 5
4 3
3 2
4 3
4 3
6 5
5 4
7 6
6 5
6 5
4 3
6 5
7 6
4 3
5 4
4 3
5 4
4 3
6 5
6 5
5 4
4 3
5 4
4 3
6 5
4 3
5 4
6 5
5 4
3 2
5 4
5 4
5 4
6 5
4 3
4 3
4 3
6 5
5 4
5 4
4 3
6 5
5 4
5 4
3 2
5 4
5 4
4 3
5 4
4 3
5 4
5 4
5 4
6 5
4 3
5 4
6 5
4 3
5 4
6 5
6 5
8 7
4 3
6 5
4...

output:

926941185
598946612
926941185
598946612
926941185
598946612
598946612
926941185
926941185
308980395
598946612
499122177
598946612
598946612
308980395
926941185
688183607
308980395
308980395
598946612
308980395
688183607
598946612
926941185
598946612
926941185
598946612
308980395
308980395
926941185
...

result:

ok 222358 numbers

Test #41:

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

input:

200002
6 6
4 4
4 4
5 5
6 6
6 6
5 5
5 5
4 3
5 5
5 5
6 6
5 5
3 3
4 4
7 7
5 5
7 7
7 7
3 3
4 4
6 6
4 4
5 5
6 6
5 5
5 5
4 4
7 7
3 3
6 6
4 4
5 5
7 7
5 5
6 6
4 4
5 4
6 5
3 3
4 4
5 5
6 6
4 4
4 4
6 6
4 4
5 5
5 5
4 4
5 4
6 6
4 4
6 6
3 3
2 2
3 3
6 6
6 6
6 6
5 5
7 7
6 6
6 6
6 6
4 4
5 5
7 7
5 5
6 6
5 5
4 4
3 3
4...

output:

101552997
570425345
570425345
958631482
101552997
101552997
958631482
958631482
598946612
958631482
958631482
101552997
958631482
299473307
570425345
661424143
958631482
661424143
661424143
299473307
570425345
101552997
570425345
958631482
101552997
958631482
958631482
570425345
661424143
299473307
...

result:

ok 200002 numbers

Test #42:

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

input:

166600
6 9
4 6
6 8
5 7
5 8
4 6
5 7
3 7
4 6
5 7
5 6
5 8
5 7
5 7
5 7
4 6
4 6
5 7
5 7
5 6
5 7
6 8
7 8
4 7
6 8
3 5
4 6
6 9
5 7
6 8
4 6
5 8
4 8
6 9
5 6
4 5
5 6
5 8
6 8
5 7
5 6
6 8
6 8
4 5
8 11
6 7
7 9
5 8
5 7
5 6
6 8
3 5
4 6
4 6
5 7
5 7
4 6
3 5
6 9
6 8
5 7
6 9
5 6
6 7
6 7
5 6
4 6
5 7
6 8
6 8
6 8
3 5
6 9
...

output:

485493133
332748119
401724376
671258108
489759135
332748119
671258108
323241035
332748119
671258108
126761188
489759135
671258108
671258108
671258108
332748119
332748119
671258108
671258108
126761188
671258108
401724376
877826765
2
401724376
156866973
332748119
485493133
671258108
401724376
33274811...

result:

ok 166600 numbers

Test #43:

score: 0
Accepted
time: 54ms
memory: 35096kb

input:

105341
5 13
4 9
5 17
5 11
5 17
5 16
6 11
4 12
5 17
6 14
6 16
7 13
5 16
4 14
4 10
7 13
7 17
4 12
6 19
5 14
5 8
4 11
4 11
4 13
6 14
4 12
3 15
4 14
5 14
5 15
5 16
6 15
4 11
5 10
6 17
4 11
5 12
5 14
6 12
5 11
3 12
6 15
6 11
4 11
5 17
4 16
5 15
6 13
5 13
6 14
5 15
6 12
5 16
5 12
5 14
5 12
5 13
6 16
5 14
...

output:

597686694
907494870
102685240
627046821
102685240
225276651
897356188
7
102685240
632164101
520904669
628061442
225276651
117440522
691092249
628061442
957640637
7
265388054
979368359
489759135
614304223
614304223
199648879
632164101
7
915617571
117440522
979368359
750668415
225276651
740332994
6143...

result:

ok 105341 numbers

Test #44:

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

input:

58827
5 25
5 33
5 31
4 23
4 37
4 33
6 40
4 23
6 25
6 25
5 23
4 18
4 28
6 34
2 18
5 19
4 25
5 30
4 20
5 37
5 16
5 32
5 31
6 33
5 32
6 38
3 28
5 31
6 31
4 36
6 31
4 28
5 36
2 16
5 20
5 26
4 43
6 31
6 22
6 26
5 27
5 23
5 38
5 32
5 30
6 26
6 34
7 29
4 18
4 20
5 28
6 31
5 32
6 29
5 31
7 32
4 28
4 35
6 36...

output:

766733961
112099256
694087273
319438222
537516269
228170200
746506257
319438222
639221908
639221908
510479661
855638034
128805767
163490645
557872612
3480834
665496270
784836758
607627019
589877372
225276651
979299947
694087273
343156839
979299947
668368013
996019599
694087273
700198254
230364156
70...

result:

ok 58827 numbers

Test #45:

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

input:

18350
4 110
6 85
5 46
6 97
6 80
5 130
6 123
4 127
5 79
6 132
5 149
6 120
6 112
4 113
6 117
7 79
5 87
6 162
6 66
4 146
6 116
5 90
5 92
6 135
5 124
6 96
5 94
6 160
6 133
3 112
5 110
5 83
4 103
6 131
5 84
4 117
6 89
4 100
4 143
5 111
5 119
7 98
6 126
6 101
7 121
6 82
5 124
7 79
7 50
5 90
5 89
6 104
5 1...

output:

795062610
662217685
887102519
628019598
903919192
68745952
585797672
278580804
655515573
697034508
690769496
17003512
842517899
112845791
692980971
828951760
351058689
651984020
82316589
958047899
88897200
436221463
555705730
991402065
422835256
303957072
413524980
550346319
614049884
310379215
9800...

result:

ok 18350 numbers

Test #46:

score: 0
Accepted
time: 46ms
memory: 35032kb

input:

1972
4 1346
6 1056
4 1288
5 879
4 970
6 564
5 1151
5 918
4 931
5 879
4 660
5 1090
5 637
3 1156
5 837
5 763
5 1267
6 550
4 948
5 1138
5 937
3 548
6 1062
4 1204
3 911
7 1567
5 1203
6 819
5 818
6 1100
5 997
5 1367
6 791
6 958
5 902
4 1038
6 947
5 857
5 637
6 1250
4 1260
5 1311
5 1111
5 716
4 1243
4 896...

output:

865159421
831651513
593946714
914587770
126249843
600031681
718873779
687098882
741515238
914587770
131018442
119910739
477808813
692405372
660322578
369586962
672645978
112485367
144911639
622077191
265987775
432936359
452444591
86103145
483163124
773466723
878638036
670737403
899756295
588547514
5...

result:

ok 1972 numbers

Test #47:

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

input:

195
6 10524
5 12114
4 11376
3 14485
4 8867
6 8296
5 10736
2 12137
4 11191
6 5670
6 10834
4 10347
7 11151
5 9001
3 12121
5 11454
5 11894
4 10467
5 9650
6 13309
5 9048
6 11611
4 4724
3 7622
5 11954
5 10916
5 11992
6 3258
3 11914
5 9674
4 13826
4 12820
6 9958
4 7293
4 9094
5 8764
4 10571
4 9077
6 9127
...

output:

129813387
575678237
477863733
710784285
775571816
773142014
554542486
89966719
674035020
281617447
258709823
766971681
819712920
728500374
685357898
68706407
319180439
864349618
701690629
140322658
662342165
453151712
143306337
550285616
968965461
581118222
170399194
746541733
617957787
136779309
52...

result:

ok 195 numbers

Test #48:

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

input:

61
4 32443
3 45142
5 22275
4 23474
5 29345
5 27307
5 41583
7 31592
4 24804
7 46684
6 32637
5 34510
4 48248
6 38169
5 36733
6 36701
6 31838
5 27759
6 19008
2 22348
5 25054
4 29194
4 22854
4 39360
4 33235
6 36396
4 47236
5 27959
5 44254
5 29082
3 37164
4 45173
5 35562
4 30261
4 32009
5 26210
6 35445
5...

output:

229706243
981754807
975196497
88733057
186086499
47466216
956968127
995290155
964621493
782070008
476574726
912032366
584515013
761013976
929841884
702952505
916278848
264129185
626253115
107151074
782605321
302302320
662061752
653723080
227699400
902046994
182679255
481454520
911069658
153681211
33...

result:

ok 61 numbers

Test #49:

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

input:

105195
10 9
14 13
8 7
11 10
10 9
10 9
11 10
8 7
13 12
8 7
9 8
7 6
9 8
8 7
10 9
12 11
10 9
15 14
10 9
11 10
12 11
8 7
8 7
9 8
9 8
11 10
11 10
10 9
11 10
9 8
11 10
8 7
10 9
7 6
12 11
11 10
11 10
11 10
15 14
11 10
6 5
8 7
11 10
10 9
11 10
11 10
9 8
11 10
9 8
11 10
8 7
8 7
12 11
10 9
10 9
9 8
10 9
8 7
1...

output:

334869712
163372652
134960775
622327734
334869712
334869712
622327734
134960775
440867421
134960775
539610409
688183607
539610409
134960775
334869712
177807924
334869712
932709606
334869712
622327734
177807924
134960775
134960775
539610409
539610409
622327734
622327734
334869712
622327734
539610409
...

result:

ok 105195 numbers

Test #50:

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

input:

99915
10 10
9 10
12 12
9 9
6 6
9 9
8 8
11 11
8 7
8 8
10 10
9 9
7 7
12 12
13 13
9 9
9 9
12 12
11 11
14 15
7 7
13 13
9 9
8 8
11 11
11 11
9 9
6 6
8 8
12 12
10 10
6 6
11 11
10 10
12 12
9 9
11 11
5 4
9 9
15 15
12 12
12 12
8 8
9 9
14 14
13 13
9 9
11 12
14 14
9 9
11 11
9 9
11 11
12 12
7 7
11 11
8 7
7 7
11 ...

output:

56894028
38188698
884169768
347599278
101552997
347599278
278918935
276045769
134960775
278918935
56894028
347599278
661424143
884169768
619861120
347599278
347599278
884169768
276045769
800092727
661424143
619861120
347599278
278918935
276045769
276045769
347599278
101552997
278918935
884169768
568...

result:

ok 99915 numbers

Test #51:

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

input:

90847
5 7
10 12
12 13
10 13
11 13
10 12
13 15
10 12
11 13
11 12
8 9
11 14
10 12
8 10
11 13
8 10
9 11
9 11
14 17
9 11
10 12
9 10
15 18
9 11
9 11
12 14
11 14
9 9
12 13
12 16
7 9
12 15
7 10
9 10
14 17
8 10
11 13
11 13
10 11
10 12
9 11
10 11
8 11
9 10
10 12
10 10
11 14
8 10
11 14
8 10
12 13
13 16
10 12
...

output:

671258108
374710197
68603191
583321633
789564870
374710197
398749421
374710197
789564870
591060075
683801260
163159484
374710197
760178656
789564870
760178656
973433586
973433586
426005512
973433586
374710197
38188698
810652847
973433586
973433586
578026271
163159484
347599278
68603191
805621385
176...

result:

ok 90847 numbers

Test #52:

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

input:

68974
11 16
9 17
9 20
13 22
15 23
9 17
10 19
9 19
15 21
10 22
9 19
4 14
6 18
9 22
7 15
7 14
14 18
11 17
4 10
9 17
11 22
10 20
11 19
12 18
10 17
12 19
16 29
9 14
14 23
12 20
11 22
10 20
13 25
5 11
14 26
9 17
12 22
12 23
14 25
11 21
9 19
12 21
12 22
10 23
13 21
8 17
9 18
10 17
6 18
10 19
11 22
5 15
6 ...

output:

279135349
412709849
872770290
746784871
577973447
412709849
684046356
305651759
895763755
706988065
305651759
117440522
116581442
341869920
94170693
599473949
847534005
282316465
691092249
412709849
66301350
507445406
278674694
542158814
507697468
693816127
232447642
588440629
45394517
399545581
663...

result:

ok 68974 numbers

Test #53:

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

input:

45414
11 35
12 29
14 34
9 29
10 35
12 29
13 25
11 34
11 36
9 32
9 39
10 38
10 34
11 22
12 39
13 54
8 37
10 18
11 47
10 38
12 40
10 27
11 29
11 36
9 20
11 25
12 39
7 30
10 41
6 32
11 27
12 31
8 42
7 28
14 38
11 40
9 40
8 30
9 24
11 34
11 52
11 41
6 28
13 41
12 36
9 37
12 32
7 35
9 29
11 47
15 39
12 3...

output:

340437776
823313877
5941856
863468361
886082067
823313877
662396115
41567587
319400557
587540868
867737820
461189312
991212835
66301350
842085602
606611761
538285186
522012490
535401687
461189312
643571825
966772711
177907801
319400557
872770290
627364133
842085602
234298457
662404247
967541337
9549...

result:

ok 45414 numbers

Test #54:

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

input:

16786
8 108
8 67
3 106
10 95
7 74
7 137
11 125
11 70
10 105
11 108
14 118
12 115
13 76
12 89
10 71
11 121
9 129
15 78
8 146
12 89
11 170
14 154
7 115
10 117
8 126
11 85
9 74
7 124
8 98
12 107
11 139
11 81
10 89
9 135
11 94
10 52
5 135
13 119
11 148
13 114
9 147
12 117
10 158
12 114
9 78
15 128
10 12...

output:

647293514
567517446
451663147
274196446
795881166
564369789
845595650
205573372
410199189
686768388
203229760
752678141
682742320
105714080
553309605
143470863
375791084
197300246
421268360
105714080
551920535
67048087
140040754
931412003
254016869
144338084
164746245
564023957
175402644
288521821
2...

result:

ok 16786 numbers

Test #55:

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

input:

1990
14 1519
10 1323
8 571
8 503
12 807
7 1129
8 1051
5 1681
10 1264
7 814
10 1310
10 1263
7 1105
11 1147
7 976
9 709
8 1230
8 1017
7 946
10 1066
12 590
10 806
11 785
10 346
9 942
11 1221
10 903
7 1254
10 920
7 1259
6 1124
3 735
6 1070
14 1098
10 981
11 818
10 957
11 1450
12 1194
6 852
6 1297
10 922...

output:

490553760
215086407
851295657
35135777
427174312
824757
596036367
731848037
876942768
445302579
634179337
221543420
327321670
596757786
493674963
437538234
226177997
613541561
963051082
77629542
135874943
113910335
567627263
91488487
895269104
985689695
334559169
40438840
822080706
635666412
8003915...

result:

ok 1990 numbers

Test #56:

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

input:

198
7 8734
14 10114
8 8614
9 9906
11 12337
13 12612
11 10912
12 14994
11 6959
11 13119
8 10565
14 9664
8 10753
11 9737
12 6078
13 5976
7 8392
8 11829
12 12842
9 5698
7 12748
7 12171
11 8402
9 8284
10 13912
13 9285
8 11893
8 9112
13 10384
9 12101
10 12140
13 11194
11 14479
9 7703
10 11692
9 13842
9 1...

output:

104529573
80566242
76107795
983343172
50064460
63515055
669931574
831387852
843464655
222267332
180251358
798829017
994439699
595215373
685955845
823263497
806849841
215755286
477797688
106594475
953257804
666955988
656013282
774940496
568982988
667650495
126266684
244485764
626028880
640154931
4764...

result:

ok 198 numbers

Test #57:

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

input:

65
13 38665
14 31711
8 40973
3 30713
13 24106
7 25560
11 17245
13 30730
8 45823
7 34827
13 13739
10 36813
4 27221
8 34875
12 44990
9 26608
9 30728
13 32593
11 22975
9 28092
7 40692
11 28930
10 31936
12 38982
12 16218
9 37344
4 39201
7 33171
14 27574
11 27238
11 20371
10 34898
8 38580
14 34569
9 2364...

output:

454253009
913850788
184005876
952732071
191981576
175572137
246102080
416255488
517188761
902103661
351650750
562593417
161337457
807113866
858091444
481948382
628523372
150935379
279177890
961464758
909671420
403886603
27381614
623002457
222359158
977214416
35689130
695368597
111571788
190907261
97...

result:

ok 65 numbers

Test #58:

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

input:

33911
31 30
20 19
37 36
27 26
20 19
26 25
36 35
27 26
36 35
32 31
27 26
23 22
36 35
24 23
30 29
35 34
37 36
29 28
24 23
39 38
32 31
37 36
11 10
32 31
24 23
21 20
32 31
35 34
22 21
26 25
32 31
30 29
15 14
22 21
20 19
41 40
31 30
22 21
32 31
25 24
36 35
34 33
32 31
36 35
39 38
23 22
15 14
23 22
26 25
...

output:

3180975
432113081
387334204
590748789
432113081
567977059
488281511
590748789
488281511
933620061
590748789
338290004
488281511
622607656
688338273
41631145
387334204
818845602
622607656
984525962
933620061
387334204
622327734
933620061
622607656
769036368
933620061
41631145
961096951
567977059
9336...

result:

ok 33911 numbers

Test #59:

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

input:

33319
38 38
34 34
32 32
30 30
31 31
32 32
20 20
31 31
40 40
36 36
36 36
31 31
31 31
32 32
38 38
42 42
27 27
18 18
31 31
27 27
22 22
23 23
21 21
21 21
36 35
34 34
23 23
28 28
37 37
28 28
18 18
29 29
37 37
33 33
46 46
21 21
25 25
34 34
37 37
38 38
37 37
31 31
27 27
44 44
33 33
30 30
31 31
34 34
24 24
...

output:

815226734
178548211
503531572
153227402
251884020
503531572
81829704
251884020
898354078
997500006
997500006
251884020
251884020
503531572
815226734
753656625
100225433
243335311
251884020
100225433
389141002
62967744
899449293
899449293
488281511
178548211
62967744
485471460
779974356
485471460
243...

result:

ok 33319 numbers

Test #60:

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

input:

32198
36 38
35 37
35 38
40 42
42 44
31 33
33 36
31 33
20 24
31 33
33 36
29 31
29 31
36 38
29 32
33 37
31 33
11 13
22 23
30 31
24 26
36 39
29 30
27 29
25 26
35 38
10 12
31 32
36 39
32 34
31 33
42 44
41 43
28 30
30 32
32 34
41 43
26 29
34 36
30 31
23 26
39 41
28 31
29 32
30 32
29 31
21 23
17 19
27 29
...

output:

689194944
27390182
545906035
493711564
239621299
896516248
298755762
896516248
495597871
896516248
298755762
44866025
44866025
689194944
726176472
172274001
896516248
789564870
522146274
255018602
555240970
462040417
661393378
203476831
694101643
545906035
374710197
115771090
462040417
479481901
896...

result:

ok 32198 numbers

Test #61:

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

input:

28959
52 63
26 35
32 42
19 27
31 41
33 38
30 36
35 43
29 39
32 43
26 37
31 41
38 49
12 22
36 49
19 31
34 41
34 41
36 48
27 36
24 38
34 46
27 35
32 46
35 46
22 28
36 45
43 53
30 35
33 41
27 38
25 34
37 46
19 27
36 44
36 45
36 41
23 30
44 52
28 36
26 33
38 42
33 45
28 35
38 47
35 43
35 47
21 28
15 24
...

output:

105897620
893393354
375038690
54659336
20380443
424745120
146412066
741663781
565140054
262747026
24828130
20380443
885221149
897072974
233348416
811412215
181043641
181043641
133676695
688265000
584476160
657495970
765877617
500496396
893076376
881281051
940757080
43859426
145761884
279509528
33843...

result:

ok 28959 numbers

Test #62:

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

input:

23782
47 72
17 41
27 51
43 67
34 62
28 59
35 61
14 35
36 62
31 57
36 54
33 44
28 51
52 70
27 43
21 34
43 63
29 53
26 43
28 53
32 61
28 52
18 34
33 47
38 66
36 57
28 61
35 64
24 53
22 47
16 40
22 40
32 66
26 44
34 62
26 42
30 45
24 31
25 45
27 49
41 66
23 46
19 38
47 79
30 58
40 59
39 59
41 67
34 62
...

output:

213089255
668582564
186035910
846037496
702851574
210327608
666065504
631268875
731291377
506005061
49767816
411011754
909319815
766198389
72047242
354059612
370487767
597914110
538985323
268765033
807680593
778288184
839647440
154240894
323079299
930908058
464619286
463877513
51456956
632054779
488...

result:

ok 23782 numbers

Test #63:

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

input:

12569
30 157
27 117
35 121
36 144
36 120
36 121
24 119
29 125
37 130
31 125
32 78
29 122
33 137
36 137
40 132
31 133
30 135
34 167
25 117
22 96
30 136
30 117
34 150
23 137
25 91
37 140
28 118
38 177
35 107
35 146
39 127
38 169
40 167
38 180
30 95
33 88
38 158
39 96
36 163
35 118
41 147
27 132
32 135...

output:

880150493
383794281
254142164
760428025
955296475
373815971
568973257
113977595
611564325
242577655
132454192
702709031
976171555
976541031
709255416
703994754
519409800
80547096
651733971
589104498
58852883
129234215
828981898
379523501
822789213
602575408
464131209
708097195
945852316
645919592
45...

result:

ok 12569 numbers

Test #64:

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

input:

1898
41 1021
32 727
36 1006
27 1091
32 1198
37 972
31 1224
32 1184
39 1021
31 1485
34 1032
31 798
38 983
34 784
26 638
36 832
32 1072
35 1343
23 888
34 1031
25 1259
29 1242
27 997
30 1110
38 980
28 1210
31 1200
37 792
31 1174
29 1077
26 944
38 879
36 1014
28 1245
32 897
38 1015
39 1054
10 1018
25 66...

output:

439638502
556391712
448475500
24389547
697100031
456470520
505031372
937470846
889856413
262629872
130530450
192859195
949698344
353645557
943667226
471922800
884168395
140729400
324536376
119026682
91859836
288405422
747145071
552447336
824321313
968186815
246526458
512843441
889968950
519970866
33...

result:

ok 1898 numbers

Test #65:

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

input:

194
36 10815
33 12924
17 10330
21 13529
37 3919
44 8620
28 10222
41 10740
28 6198
31 10678
35 10232
27 6248
28 11735
28 8989
18 9440
40 9207
39 10883
41 10885
25 8662
43 5196
32 7479
33 12709
36 5578
30 9035
28 12300
45 11772
19 7155
32 8140
32 9905
28 12892
34 10250
31 6139
40 1722
37 9665
22 12786...

output:

172560925
488555617
443622588
416012179
75578168
103396844
152954968
878846000
403359961
754695762
24613410
937115185
632637497
672206531
132493687
72868291
83562045
166580897
73844941
816835080
208928979
781866643
242670706
944444925
750998719
575010990
927581774
759621946
142317050
116446963
26101...

result:

ok 194 numbers

Test #66:

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

input:

58
24 17612
25 27678
22 47786
24 24847
22 33604
31 29558
29 36724
27 22972
23 45576
25 26537
26 47655
30 42188
35 33222
24 39297
30 40538
41 36740
30 43352
29 37548
30 34833
24 33948
28 40580
15 39776
18 45600
25 36705
25 40513
44 33317
46 48819
28 33666
21 29657
25 36117
35 59131
18 44973
37 44434
...

output:

420438622
984254681
205520706
232060805
210867683
104483645
839271037
161145243
861180048
144177062
385228979
89170422
633739152
349967862
603309648
144050491
840380695
188902881
57971008
559707667
367448751
299936023
723637517
475219620
618466833
180423150
655602983
209702907
932012194
238593251
49...

result:

ok 58 numbers

Test #67:

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

input:

10056
109 108
127 126
110 109
88 87
103 102
106 105
132 131
101 100
67 66
97 96
71 70
102 101
126 125
80 79
89 88
112 111
146 145
94 93
128 127
135 134
68 67
108 107
98 97
57 56
96 95
88 87
94 93
116 115
104 103
79 78
127 126
100 99
60 59
65 64
87 86
56 55
112 111
121 120
51 50
108 107
129 128
96 95...

output:

835914546
664119511
363674487
15229208
426933753
698979971
188793311
920640649
429291518
324602008
742106023
248494558
534291312
715484973
848102080
957309058
953214558
408901643
558615967
912099843
199810856
394493531
578947960
521963547
208046952
15229208
408901643
659472864
926368812
387535963
66...

result:

ok 10056 numbers

Test #68:

score: 0
Accepted
time: 11ms
memory: 35036kb

input:

10039
88 88
135 135
71 71
103 103
86 86
96 96
73 73
71 71
112 112
148 148
115 115
96 96
81 81
123 123
124 124
69 69
120 120
108 108
73 73
86 86
140 140
54 54
85 85
88 88
113 113
20 20
104 104
53 53
103 103
125 125
64 64
98 98
69 69
138 138
125 125
82 82
170 170
107 107
134 134
119 119
125 125
74 74
...

output:

823436669
109422602
710703019
948470318
884168763
114051362
490628737
710703019
173102472
24927130
709621105
114051362
684587537
866265286
827090259
555877700
434214798
108301358
490628737
884168763
542041015
104801467
818380462
823436669
255207814
81829704
121135700
913512077
948470318
286484457
71...

result:

ok 10039 numbers

Test #69:

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

input:

9897
60 62
139 140
96 98
104 105
82 84
89 92
119 121
70 72
106 107
81 83
107 108
82 84
130 130
110 111
122 124
115 117
38 40
52 55
83 84
102 103
102 103
89 91
145 149
97 98
71 73
131 132
88 91
91 94
114 115
81 84
62 63
34 36
94 95
99 102
141 143
113 115
82 85
100 102
163 164
88 89
88 90
70 73
128 13...

output:

148409771
870809602
8057905
807412502
857272487
74244292
319755912
581047963
113534047
482143929
846985939
857272487
965392245
289492208
124354129
36061520
773694432
973929741
485429999
130768910
130768910
759870758
155695559
730609526
247077743
636076235
453897997
128937511
969758353
421097227
7931...

result:

ok 9897 numbers

Test #70:

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

input:

9591
106 118
84 95
98 107
98 106
61 70
72 81
90 105
92 98
91 102
77 84
103 114
70 76
71 77
136 150
104 114
149 159
77 90
145 152
93 100
89 96
95 105
127 133
140 149
128 137
89 96
99 109
79 91
117 128
61 72
73 83
88 97
85 92
73 84
63 70
100 113
123 129
134 141
144 154
88 98
90 106
98 108
88 102
113 1...

output:

197451800
350332604
329640673
572030301
784003676
778723299
115046287
816354312
792310325
524668905
393121339
258392996
173051943
781044972
595747539
143569530
130758761
425181013
352079721
872695725
620271088
957574352
566985140
836974861
872695725
361017212
378692296
99541826
638532457
885149332
1...

result:

ok 9591 numbers

Test #71:

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

input:

8928
106 119
91 116
113 144
80 99
115 150
82 99
64 95
78 106
94 137
112 132
101 133
84 112
77 117
135 160
129 152
70 99
84 118
94 118
92 117
111 141
141 167
109 135
127 149
77 100
104 129
80 102
105 129
124 149
94 117
119 130
117 137
111 136
62 88
38 58
97 130
97 123
105 132
79 107
90 115
91 118
81 ...

output:

403135276
958696119
820249393
507732940
24328796
779626942
691342470
920178367
789001381
275278969
320563659
551715357
30117769
434850659
105583199
11928616
6923890
156192030
138531986
78711248
137874582
527069738
17671791
404348669
234881382
386547672
764880918
94956733
299262348
782378584
44812262...

result:

ok 8928 numbers

Test #72:

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

input:

6709
85 213
105 255
138 222
78 179
96 189
63 173
125 248
116 246
115 197
109 204
99 172
45 144
62 145
77 170
127 199
132 244
51 138
136 277
122 247
83 207
85 185
81 163
140 220
94 198
110 203
109 228
109 195
109 172
105 189
81 231
115 184
88 206
115 234
107 199
125 240
94 188
112 174
79 155
71 140
6...

output:

561537497
227926295
877636996
890279878
775067914
62209243
798594698
988239387
926766045
549960673
399462740
376100417
564725079
313108028
723719053
385252602
878265690
477469649
37652432
189084712
610428654
126178442
403130785
222549108
578472653
108692612
357327749
508647978
443934765
152294304
63...

result:

ok 6709 numbers

Test #73:

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

input:

1667
61 964
122 1082
68 1137
102 870
94 676
86 1324
127 1084
98 1268
164 695
94 1304
120 1429
91 1185
106 979
91 1360
93 1074
63 1418
87 1135
112 1094
87 902
92 1125
50 811
126 1284
132 1249
125 1150
113 1259
96 657
80 903
101 746
72 1268
136 912
137 1292
126 1338
115 768
90 1038
103 1240
69 1302
11...

output:

975656703
111435097
922926368
919885678
803592635
221728416
410996204
927082146
341316190
741301988
99412324
25848115
480154033
403679142
162632597
13113492
200407836
849710247
423267673
926297808
706572919
803554064
548423225
946748357
450082822
624945947
453746033
864832247
352634658
242099528
402...

result:

ok 1667 numbers

Test #74:

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

input:

198
97 5074
118 9470
76 9954
103 11945
111 7585
121 11616
99 13574
76 11298
116 6309
79 9840
63 9634
83 10068
94 11045
106 12127
121 9365
138 9258
109 8956
128 9219
61 8858
91 10763
123 11178
100 11272
123 7102
144 11038
98 8780
87 7979
122 11736
104 6850
126 14066
69 6688
82 2555
105 8111
100 9670
...

output:

925507741
307460698
798322038
278520332
945668675
526628536
950305246
108052996
108804270
292078708
512842347
705099728
275990831
809727489
889202377
169809322
613137530
5726483
725502096
227764214
924033618
755496057
959888694
185671102
915179450
917144992
693912278
958141596
384145281
298521377
55...

result:

ok 198 numbers

Test #75:

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

input:

58
120 43885
124 16157
66 40552
72 39751
174 44069
69 35267
83 49951
101 33304
159 43460
110 30165
136 23062
117 31921
110 44335
48 29037
63 24933
139 31613
98 28774
74 29218
55 35009
128 42269
68 26592
105 20165
69 40096
100 38586
103 24976
113 40488
94 37698
124 37905
140 37056
76 25637
129 25309
...

output:

590192124
909139548
399316259
704865834
214280142
403936871
888278921
405241302
713461853
450437645
117923324
532993501
384011619
591391274
717715706
689519119
626562411
502099293
997525139
605219314
722352697
404077845
829772355
732843290
883114738
925406503
573746108
213804955
435905568
784171979
...

result:

ok 58 numbers

Test #76:

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

input:

995
1004 1003
886 885
1342 1341
773 772
1277 1276
1053 1052
1416 1415
928 927
1291 1290
1327 1326
1024 1023
1234 1233
1123 1122
1067 1066
853 852
1156 1155
1005 1004
989 988
904 903
1187 1186
1102 1101
671 670
777 776
1086 1085
1077 1076
1226 1225
1016 1015
872 871
748 747
799 798
946 945
1007 1006
...

output:

574873189
881040846
697789680
782188172
209422409
511979657
290642819
926091838
106646374
162403915
377552561
67888563
644779835
991001123
643701479
8667649
801222566
736158131
949847806
699279984
648970446
499855829
394737076
936911194
774408896
773818761
532370595
27011367
868547089
808709898
4941...

result:

ok 995 numbers

Test #77:

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

input:

997
933 933
979 979
921 921
1193 1193
1267 1267
1203 1203
993 992
1274 1274
918 918
670 670
1027 1027
1046 1046
942 942
1029 1029
896 896
1206 1206
1502 1502
864 863
1046 1046
1180 1180
861 860
946 946
1326 1326
705 705
768 768
1008 1007
945 945
574 574
989 989
1514 1514
1132 1132
956 956
1100 1100
...

output:

824122837
362494375
745539720
374417787
129442286
939142439
981400318
853140272
640286584
816652880
471184255
822836009
450725974
116243856
200111341
145815539
166044787
523751827
822836009
48368368
517044832
116467355
738328654
376314082
529662703
569505231
550083431
249087335
325490257
279282435
1...

result:

ok 997 numbers

Test #78:

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

input:

994
1239 1241
1045 1046
1232 1235
581 584
1103 1105
1390 1392
1470 1472
558 560
1503 1504
932 935
968 970
1249 1252
1149 1151
719 721
1440 1442
934 936
1491 1493
1204 1206
1221 1223
967 969
1382 1385
1141 1142
829 832
1010 1012
798 801
1238 1239
882 884
1205 1207
1100 1103
1252 1254
1083 1084
766 76...

output:

385504583
893230051
969488430
976872933
2955430
479822093
733190516
240047637
310911794
951975930
835949076
111675388
903149374
944867451
756838890
773485412
601010138
456417795
576657264
636108188
147587452
210269503
521088342
782358081
133183805
271904679
200215534
723019941
789851286
553753960
82...

result:

ok 994 numbers

Test #79:

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

input:

995
422 433
779 785
1326 1334
932 942
1054 1062
954 958
1038 1046
846 855
1225 1236
976 986
1123 1128
922 931
1121 1130
1245 1252
1140 1149
1021 1036
996 1002
991 1000
1247 1255
1123 1133
789 800
1059 1069
1129 1136
739 745
988 1000
1017 1026
1133 1144
886 894
1091 1098
1040 1047
1044 1054
826 835
6...

output:

912777403
168471930
920087456
89407591
123671807
580964221
696136875
211540720
389032023
20615621
238630669
842222106
474549286
549462149
395654802
671506712
42719067
167607960
259090487
968364689
646355350
601759655
207901982
940844196
511947704
435291433
27968097
996063602
50694085
935913283
94000...

result:

ok 995 numbers

Test #80:

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

input:

980
1500 1527
1084 1118
885 912
1099 1128
1134 1154
1084 1104
1107 1133
1033 1067
1222 1249
869 892
1306 1328
824 844
1290 1328
1146 1177
901 924
1138 1166
958 975
1384 1408
1463 1486
1086 1109
1093 1118
693 722
987 1002
779 801
1487 1497
1082 1119
1239 1262
1287 1304
1051 1067
682 713
1343 1368
134...

output:

860587275
619953019
575981943
144223747
24349021
704923563
751167174
830910167
543722321
703652421
305075413
2330674
149840711
170576324
921637710
285177638
378974327
667180705
754554371
433223745
905076611
96400938
793937201
38146707
479418928
760464089
593234406
426902203
518436915
586851924
68474...

result:

ok 980 numbers

Test #81:

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

input:

958
979 1097
1332 1446
1072 1153
1175 1318
989 1086
753 857
1050 1172
965 1066
1036 1147
851 966
1565 1686
605 678
947 1041
1036 1139
1301 1386
900 1060
1194 1226
998 1074
1493 1626
891 987
1139 1219
974 1095
1020 1062
1407 1464
759 883
979 1068
1191 1255
913 1016
1040 1116
851 992
1079 1150
1191 13...

output:

126108921
126447317
462645164
992045721
497005297
210745928
878010481
529840369
824638202
735436627
12270803
824341792
252313570
876864144
163046354
313781672
978619532
940860545
631679694
155258743
947246807
863192760
256654904
375205593
483247666
782723657
368418908
478421257
156204437
707885961
4...

result:

ok 958 numbers

Test #82:

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

input:

662
803 1430
952 1667
1174 1804
1171 2165
1029 1906
1086 1793
831 1826
999 2064
1334 2200
1189 2109
1304 2316
1509 2734
1212 2100
952 2233
747 1938
1332 2171
935 1620
820 2055
1253 2084
1066 2350
749 1917
749 1647
637 1951
1412 1986
1140 2227
1342 2176
845 1615
1252 2337
916 1417
772 1285
1407 2391
...

output:

679589055
90191061
814639623
481138201
162284194
238050531
925248809
510424414
499204857
173989806
555476878
168705473
108841269
40533490
303839996
71035841
600507583
447419129
892985376
811934658
709986509
783664882
41004397
281826877
564636177
321257794
79379683
54055659
82541457
258593671
8133354...

result:

ok 662 numbers

Test #83:

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

input:

166
1060 8945
1303 14085
1117 13515
935 15869
823 7754
952 13458
669 11229
1121 10215
968 5731
1354 11134
681 11409
811 11808
767 13790
927 10539
1187 6969
700 9105
829 10881
1433 10029
882 10524
821 10632
1111 11614
1288 9070
772 9541
1005 11618
1070 12472
969 13405
1403 11139
827 3668
1425 11318
1...

output:

464408655
347335182
891139145
892478326
922108751
664431275
152166193
643996991
468377414
920288437
567431830
223862011
880397772
36203843
484463751
333423492
169025179
964020161
525787620
758133739
102018775
300287790
581694699
883082362
23744870
392476070
544253653
374594964
782667956
584369542
74...

result:

ok 166 numbers

Test #84:

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

input:

55
1675 36832
758 45412
635 31915
744 38113
1238 36748
764 39236
1141 29327
780 35964
1099 45586
1047 27115
1129 44644
325 41466
1411 40971
676 30498
998 28488
1238 25861
491 38514
1244 17583
1336 34113
1096 43201
1425 47131
1108 27133
1117 42445
918 36401
744 41025
1212 44856
952 37733
967 34343
93...

output:

438700587
914307534
632395518
426415055
707274446
503892862
17744535
585248524
551316721
779447855
5729520
561558128
146715530
286712262
710180133
341687480
492996344
907803822
536815907
777277083
883461160
289727806
303772124
676440806
708720133
62719829
483336444
767209820
330735429
870220718
4240...

result:

ok 55 numbers

Test #85:

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

input:

300000
1 1
1 1
1 1
3 559593
1 1
1 1
1 1
1 1
3 840405
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1...

output:

2
2
2
28851999
2
2
2
2
493120856
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

result:

ok 300000 numbers