QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#419465#1432. Kilkgrass8cowAC ✓281ms51220kbC++171.2kb2024-05-23 22:51:582024-05-23 22:51:59

Judging History

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

  • [2024-05-23 22:51:59]
  • 评测
  • 测评结果:AC
  • 用时:281ms
  • 内存:51220kb
  • [2024-05-23 22:51:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353,N=2000;
int f[2010][2010],g[2010][2010],an[2010][2010];
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int main(){
    for(int t=1;t<=N;t++){
        int yo=0;
        for(int y=1;y<=N&&(y+1)*t-y<=N;y++)yo=y;if(!yo)break;
        for(int i=0;i<=N;i++)for(int j=0;j<=yo;j++)f[i][j]=g[i][j]=0;
        f[0][0]=g[0][0]=1,g[0][1]=mod-1,f[1][0]=mod-1;
        for(int i=0;i<=N;i++){
            for(int j=0;j<=yo;j++){
                if(i)ad(f[i][j],f[i-1][j]);
                ad(g[i][j+1],f[i][j]);
                if(j+t+1<=yo)ad(g[i][j+t+1],mod-f[i][j]);
                if(j)ad(g[i][j],g[i][j-1]);
                ad(f[i+1][j],g[i][j]);
                if(i+t+1<=N)ad(f[i+t+1][j],mod-g[i][j]);
            }
        }
        for(int y=1;y<=yo;y++)for(int x=max(y,t*(y+1)-y);x<(t+1)*(y+1)-y&&x<=N;x++){
            an[x][y]=(f[x][y]+g[x][y])%mod;
        }
        //x>=(y+1)t-y
        //t<=(x+y)/(y+1)<t+1
    }
    int T,x,y;scanf("%d",&T);
    while(T--){
        scanf("%d%d",&x,&y);if(x<y)swap(x,y);
        if(x==y)puts("2");
        else printf("%d\n",an[x][y]);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 258ms
memory: 50248kb

input:

5
2 4
7 8
7 7
9 3
239 58

output:

6
1
2
20
868098448

result:

ok 5 number(s): "6 1 2 20 868098448"

Test #2:

score: 0
Accepted
time: 248ms
memory: 50584kb

input:

1
1 1

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 253ms
memory: 51088kb

input:

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

output:

2
1
2
1
2
1
2
1
2
1
1
2
1
6
3
1
6
3
1
6
2
1
2
1
16
10
4
1
20
10
1
6
1
2
1
43
30
15
5
1
2
3
16
1
2
1
114
87
50
21
1
1
10
43
1
2
1
300
246
157
2
6
4
30
114
1
2
1
786
683
1
3
1
15
87
300
1
2
1
2052
2
1
20
5
50
246
786
1
2
1
1
6
10
1
21
157
683
2052
1
2

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 251ms
memory: 50512kb

input:

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

output:

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
1
2
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
1
6
3
...

result:

ok 10000 numbers

Test #5:

score: 0
Accepted
time: 265ms
memory: 50488kb

input:

100000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
2000 2000
200...

output:

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

result:

ok 100000 numbers

Test #6:

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

input:

100000
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1
2000 1...

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

Test #7:

score: 0
Accepted
time: 267ms
memory: 51016kb

input:

100000
1 1422
1 811
1 502
1 1306
1 39
1 990
1 161
1 1745
1 1613
1 1961
1 102
1 1519
1 1192
1 1890
1 86
1 41
1 33
1 1303
1 1318
1 1522
1 1160
1 1445
1 430
1 1909
1 1823
1 1569
1 1436
1 30
1 652
1 1571
1 478
1 849
1 1291
1 694
1 843
1 34
1 1594
1 1098
1 1595
1 1084
1 268
1 1442
1 1530
1 1851
1 1879
1 ...

output:

1
2
1
1
2
1
2
2
2
2
1
2
1
1
1
2
2
2
1
1
1
2
1
2
2
2
1
1
1
2
1
2
2
1
2
1
1
1
2
1
1
1
1
2
2
2
2
2
2
1
2
1
2
1
1
1
2
1
1
1
2
1
2
1
2
2
1
1
2
2
2
1
1
2
1
2
2
1
1
2
2
1
1
1
2
2
1
2
1
2
2
2
2
1
2
2
2
2
1
1
2
1
2
1
2
2
1
2
2
2
2
1
1
1
2
2
1
1
1
2
2
1
2
1
1
1
1
1
2
1
2
1
1
2
1
2
2
2
1
1
2
2
1
1
1
1
1
1
2
2
...

result:

ok 100000 numbers

Test #8:

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

input:

100000
72 1629
1583 1130
1612 1535
1137 165
1546 1433
874 1617
998 1257
1316 1485
1051 717
259 1883
1148 770
1761 1386
626 183
728 1762
1365 1818
1142 1774
1957 887
1197 687
1223 1220
1671 1278
1261 179
238 902
1889 837
608 362
1311 94
1784 1265
1724 29
1614 1136
536 426
1132 576
1986 472
927 733
45...

output:

53839747
540654715
289433580
949687117
19878610
899747340
39967159
255343750
105085081
97587913
653841463
358441354
90261183
351281870
741547699
140806112
952903724
690771106
339901098
642135965
623798676
302089625
965229451
158930854
909775958
883859595
762326579
378566739
124732885
341793521
77351...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 267ms
memory: 50624kb

input:

100000
1545 1352
1505 894
146 1519
478 283
1475 1767
229 86
211 107
843 1576
1389 1015
40 1260
1119 804
678 1022
757 1249
1303 812
380 1195
1461 625
483 304
106 703
1309 1513
1975 909
1442 1847
1804 1085
1493 1926
1136 606
1420 1568
712 1432
1683 286
1657 1426
688 1940
575 501
990 1686
574 302
1207 ...

output:

280283696
769278165
92851217
912370371
185699644
191057149
133506894
207031101
699506200
708532379
498026649
970258829
74738280
136370558
569994106
597962372
888659780
39131384
966253917
724934081
942179455
325819274
907148296
735872068
958616738
442468308
592393767
39810420
892151821
376255957
7151...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 274ms
memory: 50692kb

input:

100000
591 1896
406 527
536 627
305 9
165 1755
346 1535
1020 1909
705 225
184 126
1782 1613
754 624
429 1441
302 335
393 973
1034 1375
223 1408
240 1681
1912 1698
406 895
1742 710
1707 1940
1223 1489
1445 1070
797 611
17 1410
1659 905
448 1101
1363 1808
1031 1342
996 1474
1747 1712
1046 1436
1346 62...

output:

120006661
950115900
912822053
2002
498971959
318683010
861599815
378063080
12168460
696643757
199607926
401721162
770160916
619548814
423587781
150313520
973144492
752657255
366123316
53822603
135323735
132392673
637682835
349156589
51895935
497917649
138107968
379952294
553656704
42923257
671650378...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 275ms
memory: 50240kb

input:

100000
1097 1047
1532 171
59 361
1671 539
1920 1168
211 1271
996 1933
1711 734
494 299
1573 1164
1213 1555
1702 188
278 1764
1061 1338
1362 282
179 1933
1019 551
1674 1175
1996 956
776 1517
824 221
1175 348
1503 1722
607 1945
451 1952
415 754
1384 1265
1220 931
1450 1149
152 61
5 1582
250 1151
1959 ...

output:

633025017
22567682
430685878
149881165
704736454
212
477645002
264182367
136666144
135632288
951202190
560149000
745354434
300237334
723071701
102773174
990205557
123662514
167616665
19192637
411917763
645819937
437310761
971543099
515240829
249908344
864811954
21311188
319391877
115376005
21
149342...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 267ms
memory: 50548kb

input:

100000
1865 608
1342 1127
131 384
356 72
941 1686
560 331
155 1435
732 260
1355 1600
329 1182
1634 926
1758 939
1121 1872
1600 1429
685 350
1596 380
1081 624
613 920
1947 1868
249 879
252 92
845 194
371 577
662 1873
284 21
441 1914
1180 807
1000 171
394 227
1611 886
1261 857
1535 1362
936 1341
1443 ...

output:

262202989
367012890
81455850
341128892
338968635
956685056
936159593
626212189
222801313
441147885
177781661
577115723
739047098
129495499
742012408
862346636
799775838
964189702
276489564
617956426
220661590
910669233
770970406
469699013
253
940395491
198097671
860305704
761363712
427993952
6360358...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 268ms
memory: 50552kb

input:

100000
911 1350
1089 1526
1153 462
1456 1618
912 1156
1679 412
1341 941
1557 124
1096 513
1956 674
1530 1959
1714 460
1556 1559
1828 780
1782 98
291 1801
1042 730
347 354
296 24
810 705
1497 1031
590 906
142 1653
254 100
1746 1464
1514 433
633 1660
1192 1986
436 58
307 897
730 771
774 235
564 677
11...

output:

865137969
783736141
554840928
519373671
100864871
290086927
961279101
638302349
755689430
493695789
579849336
592848480
519482085
448606957
1
459456381
469609554
878953238
20475
189446134
953210097
556733292
534822307
680013896
342544942
281283029
972285390
383542334
458715899
467561778
788437722
95...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 281ms
memory: 50524kb

input:

100000
1572 1350
3 814
219 1708
559 755
668 1980
60 407
1595 709
782 988
1764 1242
819 1471
1643 1531
1387 567
1234 1147
227 1626
453 1431
1480 842
340 1337
437 20
625 451
1335 1859
211 1578
839 645
1410 1771
806 1538
338 208
848 127
471 1889
86 1689
72 1359
1736 71
67 340
113 1613
1119 1786
1448 10...

output:

776236605
10
877223227
620521705
297008121
54090230
107765698
805494158
676406598
734735597
491936065
788926578
856182419
345174705
820293920
934983256
385620314
10626
292026748
72247535
428351468
493938124
390221082
465305545
633644726
401699569
577707329
672869530
471537277
437280515
1
720290996
3...

result:

ok 100000 numbers

Test #15:

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

input:

100000
1562 819
38 1716
1970 1698
1846 581
202 1618
1131 1280
144 785
1241 445
721 1719
1983 1174
476 432
78 1648
710 1194
825 352
1526 810
136 47
841 910
1319 1775
1436 742
149 646
1018 618
1161 970
306 1749
338 1295
307 1362
392 277
1484 1054
1599 844
406 1141
1555 1712
1272 1912
1560 942
1935 148...

output:

806309635
1
702097187
399400299
762547136
909674450
993116067
642863555
401794669
871375112
160646752
903041905
529877708
94176617
522489624
207327925
973180558
630240672
543704044
298390688
207744618
914113282
177433873
561928343
950003488
748825704
803169460
215290421
527791206
109605832
539593398...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 271ms
memory: 50388kb

input:

100000
726 1857
1963 181
793 292
366 893
1479 1641
1414 1858
1597 1973
746 1538
1061 1175
785 320
1365 84
798 1628
887 128
485 1470
1511 1080
106 1613
61 1352
867 500
1028 661
1627 1294
19 934
1920 885
976 210
1716 479
626 1904
832 255
209 1538
1930 1967
1691 1438
851 716
694 781
511 1576
1412 716
1...

output:

157856991
80851571
941529734
949873236
991001557
519661486
715744506
529344785
381724833
845625992
593705269
445481229
519622998
95375201
764463650
372697209
903488607
601557863
744490754
161814685
177100
748455686
904110512
602335751
930624090
542349468
709595081
447382585
872801976
813624755
19465...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 267ms
memory: 51168kb

input:

100000
838 1161
644 1131
243 1561
1196 1334
545 803
961 1624
162 1139
213 353
1795 1273
1433 1207
320 722
1392 1244
555 1772
267 1664
1312 1559
549 1789
1532 468
1713 603
478 1648
594 964
24 1605
836 1680
1770 1319
164 1698
1566 1972
1570 1020
1558 381
877 644
1949 1031
953 1658
738 387
40 1752
1896...

output:

252813357
160974847
753466957
885237498
106877464
490764412
13366
468727561
730627982
97253018
343946912
87695936
390232113
151898701
134103708
201864805
72661582
569503648
950125312
829229365
136311378
989307033
731428438
177863607
342854379
804362674
144639539
323659860
311000533
130862684
3074412...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 272ms
memory: 50480kb

input:

100000
457 1216
351 84
809 574
1734 1892
821 221
1914 1886
1668 681
684 139
1483 1543
1314 1116
1068 281
641 1424
57 232
1267 648
780 1602
1347 1370
618 982
974 380
1694 815
790 664
1873 1161
707 1040
730 316
309 1393
99 959
446 38
1307 545
942 972
1967 400
834 1988
1770 777
1632 1476
858 1126
596 4...

output:

838572241
948224318
374586614
249722857
635888770
631789887
395675982
504303902
833132796
608923612
533763892
383481553
1
804447717
682942008
404414415
747211592
180109561
827976037
755495056
810316913
420796017
193262596
401940716
444873602
535647085
679420150
537073979
586234823
963039612
10850103...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 268ms
memory: 50160kb

input:

100000
1669 1823
414 720
116 563
608 1817
880 247
1273 1022
1489 750
1838 211
1086 1932
1617 1913
667 1570
1598 1658
434 1139
179 1577
1925 402
541 1953
1397 148
1673 849
356 267
1599 819
510 1892
42 928
1609 48
1036 1865
1759 1211
1636 1789
1869 1685
1397 957
928 862
1832 839
121 570
136 1587
77 39...

output:

21857295
233944040
675791899
867429226
208433209
697641672
185544819
889636890
902826633
626171863
156890113
705813448
333089485
726127362
418587803
41305327
818287660
897479611
337322498
39620393
879827156
446567482
422249722
944092840
296786700
312443190
766650993
977332345
687288226
176276147
705...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 267ms
memory: 50984kb

input:

100000
1578 1165
995 572
1866 392
690 472
1973 1594
566 1011
220 1163
1624 1116
1851 1671
1277 1216
1992 1891
1109 16
1335 996
82 635
456 398
845 312
654 277
411 1600
1585 241
1161 10
655 858
544 676
637 1288
850 1876
1304 519
325 957
1149 1380
710 242
640 1790
401 615
1955 1671
550 1869
122 139
189...

output:

357420673
332783355
163560746
450528912
512920869
884237600
751919246
972113699
403327933
656398759
256505342
67863915
203856765
119398959
866424891
78605814
171381415
525491132
27996676
3003
149058223
844867436
376475917
150058277
308028221
196556704
288987521
768898591
370029130
813316091
61466645...

result:

ok 100000 numbers

Test #21:

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

input:

100000
418 672
907 152
902 1763
711 1965
1099 1666
1836 293
197 1737
1178 960
2000 952
661 1173
498 905
1056 1472
1252 83
109 1128
64 1055
1678 1202
1837 1747
1579 1224
1332 1764
1675 1617
26 1682
418 883
601 1043
1138 1552
528 787
1442 1843
407 771
1961 1626
201 950
1828 318
168 1610
1594 330
303 1...

output:

562858740
988628960
759862320
593199169
234975543
110658995
444614851
755253363
867336607
622257282
445838825
325497075
136126990
88527291
418996312
960600620
94051405
781251183
293141362
336183522
649466994
374206868
953094352
504098956
527613413
494445854
592154216
39333341
217200465
694744336
174...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 268ms
memory: 50316kb

input:

100000
1160 896
1986 1674
428 1500
355 1607
1641 229
714 1299
1688 1547
91 621
524 1497
1084 1994
201 291
1702 1483
1601 122
723 589
632 1558
1190 1134
377 1319
328 117
1517 237
632 1111
1547 682
1064 1250
655 321
1092 524
170 258
1391 655
1662 818
1407 563
493 222
1990 193
1899 583
435 1101
863 177...

output:

132272775
900454907
942797402
570975951
901210418
912731750
571604574
139441192
483144444
514423790
924911045
602773704
878812273
403807415
294992516
195321275
828338097
539077611
981327500
469644898
19687107
910214181
196184188
818500267
319552717
38569778
819832485
344999340
239890079
592177191
42...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 274ms
memory: 50292kb

input:

100000
670 1517
1182 2000
1388 346
1152 1345
1425 1874
1298 681
1196 1400
1302 1160
1422 1091
319 1143
1934 1211
613 322
229 1097
1123 278
1368 1774
1463 1138
946 1762
1000 507
114 1346
1494 503
141 1551
1781 1135
1834 954
952 68
331 771
1639 1155
1541 1802
1467 1419
731 405
1740 1503
302 406
463 90...

output:

27538955
254786545
1
396745568
863698244
983077149
700673340
751293877
99110343
396309250
390891867
992019128
745467431
153001704
451862332
839553101
346825821
522415944
100703578
953531748
168040077
220993588
836296463
327611386
841713559
664011873
21077841
944307811
912729795
86864906
30349798
629...

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 271ms
memory: 50360kb

input:

100000
1647 1754
883 1790
909 1339
1231 96
1911 291
46 1754
819 133
1993 1707
1414 886
1360 521
1670 1004
124 1007
414 1673
12 741
540 1678
295 1223
623 1636
1913 1645
1981 970
485 1054
406 550
854 1176
1009 217
1485 1011
1009 734
887 1292
758 665
1108 1122
799 1603
1388 323
1273 535
1407 385
1983 2...

output:

96807837
681416887
258430632
176422268
120966135
674551706
629824348
589807657
825761094
334816323
593513577
658237678
109125627
1
842405452
356290847
753579152
36431894
648211074
890050857
802750252
680310644
503981047
250490966
360803944
97996830
133096186
498214078
321813289
231093216
949880134
3...

result:

ok 100000 numbers

Test #25:

score: 0
Accepted
time: 270ms
memory: 50320kb

input:

100000
406 210
1206 1744
1683 1632
1642 1352
1096 791
1571 1223
191 1816
685 1419
969 510
1107 1989
894 721
1804 1241
691 688
1353 1248
1321 983
516 1957
1402 766
1023 1282
941 1571
264 704
99 1308
1866 1419
102 1140
1807 518
1341 1982
1770 1479
1586 179
1330 485
1212 164
1583 55
1866 283
372 1450
1...

output:

871084124
740868963
111569419
703264733
885774273
862231192
529653086
582171777
398725857
368028532
174308935
143023339
545952836
822667716
902609283
779549208
566107571
522621654
289429811
325315476
379982159
576006958
887626762
97596116
65560303
544640587
170863682
607188438
367478578
154663288
46...

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 271ms
memory: 50432kb

input:

100000
898 1954
192 1859
1617 1065
1986 342
1019 857
1067 1160
1496 1798
330 403
693 1746
282 1716
1249 1040
1458 870
1192 357
505 1752
825 928
1478 1079
398 257
84 98
535 669
700 266
994 1522
1909 637
157 1832
778 673
705 36
893 646
235 20
4 1854
1993 1548
562 169
1736 301
627 1323
1923 418
1810 18...

output:

521226936
47025019
184989788
217377037
448288833
743384451
472812188
872894273
86271822
962773563
42797900
894887518
366485369
733819016
478079259
455198663
217293079
482363677
300517590
618952458
807603996
346583356
298516641
49531322
818506122
783315785
931480269
5
248910409
85493567
734926678
334...

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 267ms
memory: 50656kb

input:

100000
1018 561
406 862
737 1376
263 11
686 1934
576 946
893 1321
1189 1817
1627 1266
1088 1004
880 217
1531 389
1831 1104
72 83
220 1957
1287 1302
446 1152
143 1461
978 418
618 1846
1408 1113
934 556
875 1495
377 68
1097 555
583 476
387 1295
1089 1976
1393 1824
536 1646
831 1341
1899 387
1027 1102
...

output:

766914339
867147887
763086496
12
574432097
36441640
887744400
543733244
279821195
335167913
47688780
621139076
594049416
729684911
7685049
677173720
719598375
109034247
793787383
232405199
873811262
124669846
514297658
32353180
767317430
904533512
946244573
791545255
461070967
418605120
154296523
55...

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 264ms
memory: 50328kb

input:

100000
665 213
1791 944
518 657
1464 290
532 1512
1854 1499
1280 1712
367 869
1866 118
953 512
1633 252
1939 557
1940 99
1771 770
1420 315
712 1268
614 726
1516 1365
1158 317
1735 1084
331 531
1673 997
1219 1857
1291 1963
10 83
938 1341
632 223
1633 1741
369 1021
803 593
1467 597
223 191
126 1821
68...

output:

737880614
672571253
200074594
207923280
864411279
574688966
333294528
951120220
905400625
248531645
321701989
656640356
403137933
291617050
263181849
449908170
480993525
94913206
540317463
60512663
423339744
981568977
544566801
837564685
3003
290856879
985838524
300519125
758325422
926602592
9385673...

result:

ok 100000 numbers

Test #29:

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

input:

100000
106 1223
24 249
593 109
1903 1222
1742 1178
1383 26
526 341
1804 1019
1972 566
1406 1936
1635 303
885 1304
694 1287
1010 1368
381 391
1053 68
601 54
585 1499
689 1906
302 1769
1770 400
1898 1510
1509 526
69 1517
410 1024
1865 469
1998 1154
1905 1350
66 436
1971 1011
423 308
1155 1673
1966 857...

output:

609915466
25
90314520
843594377
489558984
833337153
677148158
910123793
162135953
895196232
890697400
710076098
766620176
671464537
931735495
703023142
424270
817182113
578293618
829057277
301939905
708859791
19337670
949979634
112106210
418507499
379185517
378812256
842862691
671948965
431426967
43...

result:

ok 100000 numbers

Test #30:

score: 0
Accepted
time: 272ms
memory: 50976kb

input:

100000
252 275
276 851
1021 929
1130 940
731 777
1843 761
1908 1870
384 177
404 203
900 684
560 1174
334 1733
1527 1350
1174 1710
1372 289
1764 773
770 1155
82 278
211 1739
1496 1266
850 197
1085 45
1272 147
551 1885
1265 706
1925 1644
277 1476
1595 1732
16 1528
1202 1789
345 1948
52 117
1875 329
66...

output:

571179302
547514031
390798933
108903040
796867684
925915721
196049199
351318700
74261868
252244801
953975475
18929611
835462709
791483877
594908480
382877684
143798719
548132445
459373591
588524075
469228652
77876178
727418304
49302894
353522420
699767544
480215593
854512384
153
401153337
555266092
...

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 273ms
memory: 50632kb

input:

100000
1369 128
933 41
1889 954
1027 103
1807 174
136 1290
1526 944
437 432
163 1380
214 1767
1347 1123
1612 1486
1942 1183
817 1638
429 839
1091 1300
1047 124
1574 1277
1691 1888
135 354
1265 1583
999 519
876 180
331 1990
1663 1028
1442 1188
864 286
121 1020
318 785
793 410
727 1752
801 246
1011 16...

output:

257434635
991715379
927889058
992658912
862374740
804025331
521218103
494611667
392558872
478298046
887343976
506288823
851820943
907197087
496542921
399934626
776235971
192682542
573335528
93565375
873381524
883504284
784092131
55278
900756080
699315860
731606456
792756973
551907045
22559767
658057...

result:

ok 100000 numbers

Test #32:

score: 0
Accepted
time: 272ms
memory: 50344kb

input:

100000
382 730
839 308
1013 1854
1514 1385
1984 1344
1988 986
577 1784
853 134
1036 1618
164 1542
1849 1751
445 1664
1809 1285
47 1269
591 708
1137 681
1952 1298
669 1545
1247 262
1050 80
1107 1305
325 823
1343 597
1967 1962
551 373
1015 699
1744 775
795 774
868 180
851 1283
731 1338
1452 207
1627 1...

output:

224133452
249951879
325308130
216053966
804707441
846211115
863533852
180233208
35117126
317134291
655752501
467463647
701323714
876389648
46819693
146673340
95757388
199372787
21415326
91881
512673607
466519508
583955611
711506388
925643097
179270801
159990386
123712165
198963574
593917111
56876156...

result:

ok 100000 numbers

Test #33:

score: 0
Accepted
time: 272ms
memory: 50428kb

input:

100000
154 1449
1545 465
367 1442
368 426
430 1809
1607 724
750 826
213 1738
1565 254
1188 95
711 1286
572 222
1806 388
1135 480
515 597
1502 1475
1828 1081
1338 298
81 916
412 1450
1089 1329
991 590
1477 48
504 1256
697 110
461 1161
259 890
1172 1176
1063 1995
207 267
128 1051
513 247
447 1713
879 ...

output:

192421087
826887761
949333044
731553662
661518065
510142276
156438554
373353140
51780096
722003599
139005696
150774121
117568158
376612105
799029952
768310414
68798406
93623338
454002276
790096702
470851220
38601087
540044293
745481475
599604743
393653738
339139003
791878334
664559463
782012278
7753...

result:

ok 100000 numbers

Test #34:

score: 0
Accepted
time: 272ms
memory: 50980kb

input:

100000
1783 1719
1158 810
1338 654
806 1970
240 1313
1367 1601
1777 336
1179 456
851 1686
1791 1820
268 1019
1120 183
406 1867
1654 1679
1012 289
537 658
946 1435
452 277
481 615
986 1875
907 62
1919 1922
573 1807
1526 1263
1176 1945
1940 702
1202 217
287 200
431 1355
1876 476
1851 1971
600 144
1300...

output:

700007232
511941278
408185789
991294997
35811005
98700185
715350816
704982758
242634568
440407972
377906765
198943919
79217416
691987193
952368403
56992931
226907369
642613225
401613914
841806950
795665394
811400554
988376580
40050799
689249447
988878520
56751657
524727042
165403143
537412522
976645...

result:

ok 100000 numbers

Test #35:

score: 0
Accepted
time: 270ms
memory: 50648kb

input:

100000
1599 331
1085 503
1985 821
1322 1108
980 1677
1408 1765
762 938
439 148
1106 380
1856 1964
389 598
142 1748
1090 628
494 1277
1287 1367
1346 170
734 467
1131 1671
1436 963
1675 62
1850 1135
1503 1377
1597 1978
936 794
1088 1304
186 1080
1770 1103
546 524
1706 656
930 1767
1006 1797
1916 1618
...

output:

416517596
254960441
495608677
527185724
38367087
117140962
837800816
21782727
112883452
25006070
396485865
984962076
869227636
354360151
754969914
605855312
14455298
34627706
625381032
570810937
141735756
925662706
157594654
915002395
101953773
303134089
789498906
946774961
916945426
727770712
32913...

result:

ok 100000 numbers

Test #36:

score: 0
Accepted
time: 269ms
memory: 51008kb

input:

100000
1164 1639
1049 1158
1797 513
611 255
1125 971
1922 1221
808 1330
867 1329
116 1797
154 1541
1493 1245
1561 312
916 709
1857 1043
1915 1484
1413 75
1940 1600
522 495
760 964
857 238
1544 471
1731 1831
259 1350
282 229
1120 156
209 1075
1524 1858
908 1963
212 1424
157 1991
1827 420
776 1598
613...

output:

916213977
932689883
378874189
50188005
360089157
982966928
328511669
144237118
909980004
805440488
688901379
407624595
477884184
889858351
312581664
293110514
462324690
290999133
559411345
137905890
846004655
214816568
391286083
409838598
667530220
852051632
32537618
709099306
743261040
861485265
11...

result:

ok 100000 numbers

Test #37:

score: 0
Accepted
time: 268ms
memory: 50468kb

input:

100000
1099 1182
1380 196
1207 1551
1913 216
130 1004
596 438
469 320
1518 1728
414 779
250 1622
1359 878
938 1172
834 592
1486 1609
366 1358
1602 208
1336 1965
1811 17
574 1261
395 1403
33 1709
1145 1416
1573 816
304 1071
637 977
920 820
1440 1975
188 389
1471 249
319 1731
1723 1308
1803 1068
1670 ...

output:

963686317
378489610
593483524
594097951
440911958
434069717
370805668
588515130
54891838
709106936
592950792
343463049
716406183
893497539
107950034
600237688
38342284
346104
582583826
497192015
855663586
579180562
664130845
712675915
980645736
367483133
704191453
867000336
99780199
89698742
4291078...

result:

ok 100000 numbers

Test #38:

score: 0
Accepted
time: 268ms
memory: 50492kb

input:

100000
540 1884
1296 335
1320 1472
640 224
978 1265
585 1909
309 557
1222 544
1668 1697
61 1835
1843 720
1724 116
460 1018
1740 1242
936 882
1542 1501
201 1572
790 161
668 1817
1501 280
1817 1978
260 70
1490 373
793 812
980 1728
1776 1686
1317 1160
1533 977
1423 746
1443 1950
325 1439
1313 598
1242 ...

output:

236990466
790078926
12574214
741883383
597404741
315945573
759607789
702077010
743142307
984392738
794135631
730640707
517520133
755043586
4791466
804415617
99188596
68994921
718699312
873232881
273076260
956886731
721597588
12689718
103017825
626200517
410385843
722608014
884042361
162968677
392864...

result:

ok 100000 numbers

Test #39:

score: 0
Accepted
time: 275ms
memory: 50892kb

input:

100000
1365 1534
1179 1776
1067 1425
78 498
1942 1488
1656 968
648 1956
1671 1799
104 582
40 1828
381 1235
343 1698
479 360
770 717
466 1551
139 1049
528 286
1620 96
742 318
1276 1760
1953 295
488 1555
1678 951
298 986
1874 1758
1712 1257
587 702
1286 819
1557 167
369 45
479 1785
1157 1321
599 1248
...

output:

278051802
369780726
551371448
455639355
987876
385022832
485735750
888747001
21596051
86552189
652127229
856901404
225424070
167739999
429851045
284431625
305960757
361260107
707966559
319776579
339303837
908403392
555731313
332386369
496623120
530805835
755053427
420698118
134311378
252805700
12718...

result:

ok 100000 numbers

Test #40:

score: 0
Accepted
time: 279ms
memory: 51036kb

input:

100000
1571 723
1628 672
1619 928
1593 462
1616 837
265 777
814 1145
96 1815
907 1206
264 1735
133 1020
902 536
1578 709
1172 747
1586 1761
1923 780
1027 377
1529 1350
336 315
1246 1734
1423 960
1022 576
1954 1409
1916 1372
1677 1269
958 725
961 1520
223 873
487 1587
1448 1407
498 25
957 1286
120 20...

output:

186206680
354659862
434686681
636038093
656780519
783245098
191756892
303372959
953113191
465069510
414854677
995810859
791712095
186525785
927846526
30480544
457453231
924603843
888737963
650322355
6551077
675161523
363033689
651799198
699827194
514714689
703549174
791579013
630455558
804121372
984...

result:

ok 100000 numbers

Test #41:

score: 0
Accepted
time: 267ms
memory: 50644kb

input:

100000
1275 605
1275 91
392 169
89 1130
149 1757
676 39
448 976
906 754
1349 1024
1008 1090
828 1391
1017 1329
400 362
1392 247
222 1898
186 1673
842 1811
1214 204
1857 1138
491 1873
1537 1744
591 566
190 547
1081 1565
1397 42
1637 1240
116 965
411 1060
1762 657
1974 1006
1655 1745
1040 1910
338 622...

output:

207726563
864053721
499196543
343465889
507158739
123410
859998139
673604211
746071975
393995398
404487880
271645025
713801644
853561735
250490353
640252613
555686492
788795456
972256507
510911748
373701700
893441164
869860791
480519536
289754346
613247629
943025485
106239008
166747631
168399405
565...

result:

ok 100000 numbers

Test #42:

score: 0
Accepted
time: 272ms
memory: 50836kb

input:

100000
1838 645
93 1245
1719 1665
1337 1477
1561 1166
618 1997
414 922
440 544
1009 1326
1742 329
495 1092
1117 927
340 1477
751 1408
1229 811
343 551
1900 289
1989 177
26 1326
364 1901
1901 710
22 1454
1286 1683
1170 1030
379 1202
419 1123
1722 41
1356 573
421 1269
184 354
902 1560
1280 70
133 365
...

output:

633891930
178371389
786191397
920598815
53845933
763068500
220015895
320138744
163583300
470026522
313643318
835654258
568697769
51598022
175329692
437414339
412256412
569685427
431126314
579900994
594271649
578649911
302130180
696749499
222743504
528349575
1
543821511
245591418
281476593
461413966
...

result:

ok 100000 numbers

Test #43:

score: 0
Accepted
time: 267ms
memory: 51064kb

input:

100000
1471 31
1611 39
1361 1157
200 370
968 292
1617 364
1626 1211
1522 1820
88 1296
1793 765
947 5
1182 1670
94 642
1840 1197
1475 162
1350 530
1714 1112
27 1403
273 92
1900 1968
1637 1658
1505 209
1390 844
1901 1165
1593 28
1609 1548
1712 1655
1131 1979
1343 721
1085 1837
156 1983
253 1542
1146 1...

output:

32
622392528
141234974
94068205
996750376
815115719
470938668
339864364
44517035
984236763
6
854699019
165192942
855149286
421943113
455745550
746945129
65599929
53967536
394589804
824618546
863693361
365778747
995269757
435
392673293
896033354
193471719
83823692
269377214
249069422
420963101
449577...

result:

ok 100000 numbers

Test #44:

score: 0
Accepted
time: 271ms
memory: 50488kb

input:

100000
1572 1542
1167 266
364 1752
1066 907
1949 543
1994 119
1495 443
1297 178
580 1843
442 1358
456 1849
310 825
1452 586
1196 1570
1839 1124
136 1959
213 1233
49 1080
806 339
1192 1295
360 1663
409 1842
574 1311
377 1960
1651 1321
387 1151
1808 487
375 237
1422 1887
1583 33
879 1307
1355 1168
165...

output:

84644161
308626636
668150314
300860027
307731462
529908972
591079764
375858527
815298129
244996733
902721750
859885722
83253004
996751288
187913294
602721785
298664473
524306915
41166461
469261292
535828844
806678824
58545283
135259851
416421607
673739939
31946550
478194265
803307003
182512809
24242...

result:

ok 100000 numbers

Test #45:

score: 0
Accepted
time: 267ms
memory: 50584kb

input:

100000
1172 861
674 27
1803 969
579 1270
1197 322
1298 15
97 819
1340 160
746 1748
448 861
1145 1446
1608 1092
138 1815
471 363
1963 1073
1742 1913
412 1721
1764 624
1525 1097
549 127
1603 246
625 1360
1755 1183
665 351
1685 1473
830 673
1036 610
903 1710
583 945
706 96
356 1609
58 668
421 88
116 56...

output:

438006047
786421135
151394078
592373406
391833890
77558760
1664327
902860175
90326094
179061256
172142325
937280979
295943737
453162378
57881804
63717263
821075330
750475747
161611421
873274289
955103312
907490256
218751000
871930440
357289291
284798825
241285947
674243143
940765580
841478157
452449...

result:

ok 100000 numbers

Test #46:

score: 0
Accepted
time: 273ms
memory: 50484kb

input:

100000
1976 1217
550 1585
1554 1676
647 1272
1248 1124
1134 9
165 902
1581 1682
1380 1741
1093 1084
710 1998
575 504
320 496
1016 842
907 1253
292 269
1835 296
219 540
968 692
196 469
323 1991
1786 820
1985 526
691 256
1662 578
1226 1792
1338 1554
1925 623
219 888
936 934
523 605
126 1676
132 42
112...

output:

70316220
749843228
637328608
22748198
679962881
5005
436230153
897237171
243696260
42857223
513745953
397539952
840227623
173064875
538198773
487292305
195368209
229902896
433426164
537434017
315991775
807000825
980798432
131188468
50215790
154200165
283289546
40566390
652530065
583482960
675131273
...

result:

ok 100000 numbers

Test #47:

score: 0
Accepted
time: 274ms
memory: 50332kb

input:

100000
120 798
553 1053
4 1631
1117 660
296 1956
371 219
1122 189
1482 956
1659 660
1371 1542
1362 706
1866 156
107 1883
1057 681
519 1872
432 908
990 1020
826 1666
1118 596
56 107
403 1993
1891 363
945 1509
104 1162
950 45
785 1448
200 648
1437 146
107 366
1435 320
1988 373
96 558
1995 1821
271 138...

output:

995761191
792269321
70
462241149
148494065
693760283
896751428
967983094
348514583
911261135
359962177
586619354
285817327
78211625
910928764
669252682
424951597
547046380
988038910
523992240
407681981
178489922
351483899
302270366
140536118
930277629
134920787
770529151
575198668
370323303
24957287...

result:

ok 100000 numbers