QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#804903#1348. Cactusnullptr_qwqAC ✓1841ms139152kbC++143.5kb2024-12-08 10:00:382024-12-08 10:00:39

詳細信息

Test #1:

score: 100
Accepted
time: 7ms
memory: 32376kb

input:

4 4
1 2 2
1 3 8
2 3 0
1 4 6
4
2 1 1
1 2 2
4 1 1
4 3 2020

output:

2
8
6
-1

result:

ok 4 number(s): "2 8 6 -1"

Test #2:

score: 0
Accepted
time: 720ms
memory: 134780kb

input:

100000 99999
6753 26593 273730672
19068 88596 857001051
70559 41558 1055416999
85577 60725 874090067
24686 22090 997210338
60993 2465 788417925
60046 34652 715733279
66388 11390 420960945
10446 7794 716306086
44937 16631 890815128
14003 26404 990237976
79133 75626 109227304
23083 9502 288860916
8951...

output:

590505814
70955362
-1
849119091
661176388
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
390056894
-1
262404322
-1
-1
-1
437329346
-1
-1
-1
205989264
-1
242338416
-1
198962670
-1
859066934
768872434
-1
-1
-1
940778076
-1
-1
-1
-1
-1
1000309954
-1
-1
-1
-1
-1
438126027
-1
-1
955360618
-1
-1
-1
-1
987744593
-...

result:

ok 200000 numbers

Test #3:

score: 0
Accepted
time: 164ms
memory: 32688kb

input:

19 18
15 13 836933916
5 6 237414782
4 1 998388019
14 5 67303928
16 1 55432676
8 15 124905
9 3 365009569
6 11 280964098
18 10 646687557
7 3 863955999
14 12 697031095
17 10 989091403
8 19 459924546
2 13 1018382425
17 12 341586591
2 4 949018040
7 16 898606272
19 18 280525260
200000
18 3 6
11 12 1
12 4 ...

output:

-1
856728883
909293835
-1
276629402
-1
755887490
-1
-1
1041331866
-1
-1
1037560616
901835540
-1
-1
732142642
366648776
-1
657046788
786246289
463140189
-1
-1
-1
-1
-1
-1
-1
-1
820187333
-1
-1
-1
-1
-1
-1
659330988
-1
-1
-1
465279300
1041331866
-1
-1
446397572
-1
-1
-1
-1
198286734
434944679
-1
-1
-1...

result:

ok 200000 numbers

Test #4:

score: 0
Accepted
time: 123ms
memory: 31848kb

input:

17 16
16 15 401000771
1 11 742997674
8 4 828999584
17 9 150601451
1 7 956346061
12 6 643191283
3 15 809400568
5 9 755875859
6 2 804563709
7 10 758378683
13 10 883710500
12 17 91449123
2 8 558455955
14 16 896412965
4 13 461318173
5 3 78015735
200000
13 15 1
14 13 1
12 15 8
6 4 15
16 15 10
5 7 4274
3 ...

output:

383927796
879403410
-1
-1
-1
-1
1061394323
78015735
-1
-1
215366392
-1
870633105
-1
-1
947544284
1070887374
-1
-1
-1
-1
109765556
-1
-1
-1
-1
-1
-1
-1
401000771
-1
595516748
141360710
-1
-1
783051523
-1
-1
-1
-1
-1
-1
650155333
-1
-1
-1
-1
-1
-1
-1
-1
-1
215063597
-1
511446575
-1
771033869
-1
-1
-1
...

result:

ok 200000 numbers

Test #5:

score: 0
Accepted
time: 189ms
memory: 57784kb

input:

26383 26382
23188 7797 257839641
17381 19457 659307649
20282 14411 479037447
18973 16372 790930565
3542 3394 1024612184
13629 412 925009328
22894 6952 655845794
21196 20852 550704976
4018 12583 915482240
19664 7424 858532495
26310 2734 862709803
19796 19847 25821390
4850 16755 927882832
9543 21514 1...

output:

-1
713856492
-1
-1
84084599
-1
201201121
-1
-1
-1
-1
-1
52164891
-1
-1
631254957
407430397
-1
-1
867759748
-1
803616057
90786760
-1
-1
696013722
654067646
-1
116988064
-1
-1
-1
-1
763519801
720925831
-1
49523557
-1
493370317
-1
730187293
296075152
719825857
-1
-1
95208238
969557918
-1
178031900
-1
-...

result:

ok 83698 numbers

Test #6:

score: 0
Accepted
time: 636ms
memory: 126836kb

input:

96793 96792
78075 15060 824586780
92643 86054 1003696995
47749 49812 45765909
17317 90255 117499920
92185 20061 603414045
9140 61499 312955225
38627 52090 132419953
19027 55728 951104943
20048 43084 256816621
16387 13404 401220823
32034 8347 1023190324
95681 24395 955346751
11656 1351 671197278
5800...

output:

277751446
-1
125481881
-1
-1
828214477
-1
760894922
-1
-1
886841174
-1
-1
-1
-1
-1
1064476823
-1
-1
-1
-1
416770675
655909808
-1
-1
-1
123810867
-1
866017956
-1
-1
-1
472163072
-1
-1
-1
397856482
-1
-1
-1
-1
-1
-1
351455210
12810316
-1
208266315
-1
-1
600735383
-1
-1
-1
271804271
-1
-1
-1
-1
7384613...

result:

ok 114109 numbers

Test #7:

score: 0
Accepted
time: 686ms
memory: 103180kb

input:

99999 133332
42278 62690 420434985
5936 9523 770170039
4780 30222 617388703
18656 78697 631255376
3091 47764 519490157
12229 19099 348569879
41322 74985 38416019
48960 98674 108652441
34614 80016 885357080
27398 12142 358985974
95202 50217 708540733
10892 72997 746120496
64797 14148 937652266
63608 ...

output:

672582142
-1
72655980
-1
283026725
-1
-1
-1
715573446
91317166
-1
-1
345725847
530520383
-1
-1
-1
179994931
120391003
152652184
499947246
283097490
-1
-1
823366588
110110708
-1
20483870
592131625
547032991
1032837687
389862729
333961064
835926089
-1
582634969
522220592
148163737
-1
-1
543732516
4702...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 710ms
memory: 103212kb

input:

99999 133332
31916 16156 354889464
98547 21442 619494263
9958 36139 220684608
59670 21038 1057578696
20635 8641 496087525
23596 36423 389071753
13457 92538 1014093161
94639 99382 773670736
58682 68223 776778843
73665 92438 660694558
76856 67269 715460274
78179 94626 158600429
44886 2400 54194217
728...

output:

167811456
558926192
259855945
122964635
-1
121039028
338567232
-1
258654792
161848241
683288759
178644724
494200897
503269608
-1
363133496
-1
174468189
1052426575
2522967
-1
-1
186324117
679976909
210886918
-1
565142305
64383599
-1
270074090
-1
-1
-1
330749933
-1
493405533
607614127
-1
963088749
-1
...

result:

ok 200000 numbers

Test #9:

score: 0
Accepted
time: 202ms
memory: 32520kb

input:

18 24
17 9 100015221
18 12 139263264
10 3 65015194
16 2 237548025
12 17 354154633
10 5 705741683
4 1 578519218
8 15 183883925
2 6 163465131
9 13 711894792
8 11 40948648
13 17 116908607
17 8 54334104
1 10 797898556
16 12 623632296
15 11 791162263
7 4 265253369
10 8 252360492
12 14 326316670
18 14 162...

output:

-1
-1
-1
311770853
-1
457166686
222143161
420065334
262144250
-1
182644393
390277881
860550020
592417649
482608312
183883925
193992829
801714433
60741250
808462113
265791534
111225962
10430664
602462452
-1
222582823
-1
66155334
-1
-1
21872944
229814707
-1
44962697
-1
113970925
-1
245000478
418935106...

result:

ok 200000 numbers

Test #10:

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

input:

12 16
1 10 778915609
2 12 31043905
12 7 893430230
9 3 782602639
4 1 445252445
9 5 932789911
3 5 162335424
11 8 448476564
8 2 867282646
2 4 286186023
4 10 337821093
8 6 417616124
7 2 525744289
9 8 732321248
11 6 992635686
9 4 460409694
200000
8 2 6
4 3 4
6 10 1
11 9 83
7 2 3
8 4 614
4 9 7
1 7 1
5 2 1...

output:

-1
925701446
90504617
-1
-1
-1
-1
112888724
-1
483656198
152641809
-1
-1
-1
22526444
193255802
13811129
144612437
-1
-1
162335424
-1
35127107
-1
-1
224585722
33245187
654875471
39806312
992635686
654875471
-1
-1
-1
-1
-1
356572174
-1
-1
245939960
-1
121346241
-1
430391201
70275834
63592706
123837249...

result:

ok 200000 numbers

Test #11:

score: 0
Accepted
time: 504ms
memory: 93704kb

input:

93579 124772
13418 37191 264424930
59725 44627 440841945
82331 28337 450431621
378 11465 92400267
62838 46355 35340113
27615 26455 159738191
35487 61514 704055651
20228 25370 1050519302
52291 13282 926358383
64298 44524 788265124
59265 24185 815663812
80454 88372 1001699475
49619 80358 1038303919
58...

output:

-1
-1
1934309
268915281
-1
319599133
-1
-1
159077688
-1
-1
-1
-1
-1
806522589
504192597
25086895
-1
-1
-1
192219355
350304895
888140882
681197213
-1
-1
103634232
-1
-1
-1
546984845
406307092
-1
538740519
-1
41877498
23045642
-1
-1
793353675
290041125
871976980
81641004
-1
-1
187082718
762179729
-1
-...

result:

ok 117809 numbers

Test #12:

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

input:

5334 7112
3556 1626 100062190
326 1197 212972868
5260 5085 929307675
2459 4742 7129954
4536 5316 763059520
3026 793 408486099
2719 1031 489488360
3145 1544 64948698
5036 959 830000514
4361 5284 524110461
3937 3885 771156391
963 1361 480396876
4674 100 874424661
537 1434 334275810
5094 1526 966630894...

output:

945125653
551813750
449512972
590153100
-1
226843358
-1
-1
-1
115463712
-1
217535922
-1
-1
547542539
-1
56462263
-1
-1
-1
482786529
-1
651610601
-1
-1
227441833
235246630
604920344
-1
958076306
914818072
-1
-1
17635952
251395969
170069715
127514863
-1
624084889
241875863
-1
215302051
1001905183
-1
1...

result:

ok 168540 numbers

Test #13:

score: 0
Accepted
time: 457ms
memory: 97296kb

input:

100000 100000
43596 88343 228704974
42475 6525 710158284
37996 88513 498630777
36068 80750 713053662
91211 51821 815571552
92136 50685 637759112
61668 3553 181414451
2540 41285 441127361
79305 52762 712079122
81578 64134 948229725
9955 44929 438128231
84548 91231 254557428
16377 21778 374166391
7575...

output:

388050812
-1
717216810
-1
616444172
-1
-1
-1
-1
-1
410053940
-1
471685161
-1
112413665
-1
-1
881515885
295167044
-1
-1
-1
-1
-1
990356512
-1
-1
-1
-1
77868120
498820334
-1
169901021
-1
180630088
-1
-1
-1
-1
870647422
401959706
613498206
-1
-1
578459464
-1
-1
621898288
-1
-1
-1
-1
-1
-1
-1
-1
-1
4972...

result:

ok 200000 numbers

Test #14:

score: 0
Accepted
time: 515ms
memory: 95096kb

input:

100000 100000
39442 30327 587460196
35255 55549 526821530
68208 58758 700890053
38148 33214 1034071870
86784 43980 51672914
98235 90817 854291624
22642 97768 164104086
76104 45129 156160097
48343 43818 108178305
28148 10841 212753134
29219 74450 1047436257
49001 36886 908904351
45040 38042 105239553...

output:

-1
435680662
-1
-1
-1
-1
-1
706930619
-1
385033026
856290848
-1
291183625
482469336
412963282
-1
-1
56339784
166283414
265254145
-1
1011112283
-1
731574479
144373195
118159278
-1
-1
-1
-1
-1
-1
1014926925
-1
230748717
305869883
-1
-1
508672084
996356160
33016084
-1
-1
94949528
-1
-1
-1
-1
245454984
...

result:

ok 200000 numbers

Test #15:

score: 0
Accepted
time: 199ms
memory: 32580kb

input:

20 20
11 10 456314404
12 14 948276929
8 3 325123674
6 3 727603958
6 10 613256954
19 7 252946257
18 20 647361611
4 9 162176906
19 5 89347626
2 20 449693744
17 2 563379993
8 15 374136990
1 17 214073440
16 7 385294156
9 5 120905769
18 14 395957809
15 16 520831099
13 11 820047199
13 1 1017507897
12 4 89...

output:

-1
-1
905115703
-1
929106221
705900227
-1
-1
767094124
786742130
-1
217981115
-1
226421941
-1
-1
-1
-1
499925858
964521283
-1
957920262
684832388
604108663
-1
155689189
-1
-1
96133508
225710418
-1
8887558
783831959
-1
-1
786742130
214073440
-1
948276929
-1
-1
161505901
-1
-1
-1
-1
-1
-1
930424156
-1...

result:

ok 200000 numbers

Test #16:

score: 0
Accepted
time: 186ms
memory: 32272kb

input:

17 17
9 1 557023632
10 3 466333301
5 7 656384469
7 14 188064214
3 6 235024239
12 10 474891049
16 8 716909100
13 11 102319385
17 4 251221792
17 8 574410675
4 14 330561047
6 1 376928610
9 15 1038543455
13 16 836328451
11 2 659092221
2 15 854027834
12 5 203876012
200000
13 9 3
14 17 1
16 5 11
10 7 4
7 ...

output:

-1
163665523
-1
-1
-1
740950019
804344721
228539447
-1
62847096
-1
53791490
743418857
-1
-1
603779860
-1
548473504
644754217
768418009
-1
9057146
-1
147174509
255875377
-1
906399404
605296811
365527322
-1
-1
-1
-1
701346012
695185228
-1
-1
121110867
-1
-1
-1
180621168
-1
-1
21132894
-1
-1
855833783
...

result:

ok 200000 numbers

Test #17:

score: 0
Accepted
time: 164ms
memory: 49616kb

input:

26564 26564
7362 10141 597185581
12382 14928 789695060
12479 11727 105966138
25083 21339 336424928
756 25546 82324230
6027 25583 808864393
731 2753 137996098
20719 26267 202375155
8112 14978 467216146
1738 917 592052573
13858 6975 227810151
12765 24846 594338439
23672 935 327578021
23329 26144 34627...

output:

428510550
227089882
-1
997015222
966773609
332397972
-1
-1
762665590
-1
1069640210
-1
-1
-1
641701661
542153173
-1
-1
-1
-1
770426752
223464027
-1
762665651
-1
207960549
945408505
597249935
339547896
-1
661894741
575479638
-1
-1
-1
706835467
-1
613033405
554468875
632084881
569806135
-1
-1
831818565...

result:

ok 87878 numbers

Test #18:

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

input:

8068 8068
325 3655 475312353
3463 7889 502170355
6262 390 14420497
435 2943 861547514
5293 3831 95287307
3684 43 626245939
1324 3661 875872660
2960 1662 465254628
2708 6674 918252053
3806 2645 455832449
507 6871 510483631
5296 2778 351945345
579 4274 999500414
7056 6768 798105104
4562 1996 118380613...

output:

-1
152674117
-1
-1
-1
-1
-1
-1
-1
847491945
705454892
-1
242416061
-1
-1
288023121
-1
-1
-1
713173959
257389101
-1
-1
-1
-1
477175226
887915641
-1
200496205
676223674
-1
-1
-1
794121667
109958496
-1
733207304
568038508
-1
560568843
-1
1001739690
-1
-1
243370433
-1
949330908
-1
-1
-1
989306532
-1
567...

result:

ok 21734 numbers

Test #19:

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

input:

4 4
1 2 1
1 3 8
3 2 0
1 4 7
4
1 2 1
2 1 2
1 4 1
3 4 1073741824

output:

1
8
7
-1

result:

ok 4 number(s): "1 8 7 -1"

Test #20:

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

input:

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

output:

3
3
7
10
7
-1
2
-1

result:

ok 8 numbers

Test #21:

score: 0
Accepted
time: 1731ms
memory: 101148kb

input:

100000 144825
30669 27642 658024914
99747 48719 1009377193
34466 29141 93446198
81100 42768 346517209
86424 75544 507399151
57357 97679 681235992
48524 53464 825201912
72030 46338 403628568
13169 59507 24089570
68930 91798 536481794
37148 45642 629795755
14492 72308 703117397
98056 74565 608257846
8...

output:

0
7
0
19598
6
28
154442
57254
0
0
50
0
0
111
1
1958
26
1
53
1
0
870
2649
9
0
1
14
7
0
7
0
0
9843
870
24
0
90
12
141
1
0
0
26
83
220
1
8
1534
0
6121
7
1
0
3400
1837
3
0
51
24
0
117
11579
2
0
1
1
31
2
5
295
1802
1
13761
0
18
3
10
0
94
1
0
1
33
2
2
0
3
1
19
0
2
116
0
0
3
6
1824
6
0
0
7
3
256
0
0
0
1
1
...

result:

ok 200000 numbers

Test #22:

score: 0
Accepted
time: 1758ms
memory: 101156kb

input:

100000 145179
49489 16325 720757773
80537 9779 30501433
15164 72959 335493083
11197 55691 781617751
33115 73241 964501857
31577 27250 713496651
76981 59912 957326653
18586 65561 498880910
2734 32034 63793243
19379 23733 787434098
86813 3276 841917825
15801 48283 758251570
199 79827 754052793
81931 8...

output:

1
3
28292
37
1
0
3
1
184
3
0
0
9
22
0
0
112
49
60072
2
207
0
0
19
0
5
0
93517
205
115
9
1
0
37
0
1
0
3
1
126
166
0
1330
0
0
0
1
0
0
1
0
15
1
0
0
53
10
2
5
2
56
0
2
0
9
0
123
14
3
37
2
30
1
71
0
5
7
14
74
0
260714
0
5
0
19
0
228543
0
0
116
77
246
3
12
0
5
172
1
5864
14
473
1
0
0
18
250
822
0
0
10
135...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 1841ms
memory: 101996kb

input:

100000 149712
38193 32982 1050238794
5222 82857 150861199
47085 93 895071227
33920 72732 404013101
56431 38151 34571043
35765 77470 815672010
55452 49134 793287775
38486 8409 91491796
35782 57642 682328197
67324 65569 761417601
90857 79384 590589201
65130 84796 585275252
61037 5406 251472938
60621 6...

output:

3
13
3
3
2
0
1
0
1
10
91296
11
0
0
3
0
0
24
1
22
1
56
0
1
1971
21
3
3
0
2
1
0
15189
3
5
12287
2
1
4011
0
1
413
127510
2
8
158
4
0
2
1
5
119624
287
12420
0
113
0
63
0
0
160
28
0
191
401
20
3
4833
0
950
1
0
27986
12
0
1
17
1
0
75940
0
3
13
1
10
8
0
1
1428
0
0
1669
0
18
0
460
14
877
1
470
6
1
30
0
0
1
...

result:

ok 200000 numbers

Test #24:

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

input:

1949 2769
1729 1277 1041001679
813 1219 146802618
1761 718 559240302
470 1493 621152477
1882 606 1007803253
1088 1766 213539004
1613 308 549025624
566 585 755605821
90 845 147530647
1155 791 258202449
1414 760 289915060
1840 1050 849976109
975 357 800331904
1941 619 1025454245
1471 809 241810632
106...

output:

-1
2969
0
2
517
2107177
29
0
365
14313
278
7264
101
911017
211
768
2896
65739
5851
2357460
2017856
663
4
280
1049885574
442
368
434
303
14
73
426344
100770
269
58
5
226631105
14809
74
13
39
1398576
0
3022
15746579
5
93508
1630
7
8
494
150750
50
48227
122642
64902
1302
208
0
36842
11745
38311
0
2370
...

result:

ok 70778 numbers

Test #25:

score: 0
Accepted
time: 509ms
memory: 33424kb

input:

1949 2846
1764 1286 962970747
1560 559 205464689
1059 1320 827947825
1270 986 698309329
1459 427 101989212
680 505 526671269
1625 243 417156347
93 122 734656106
1810 1734 68140133
1470 1824 805747344
1695 1556 941497961
952 220 79433530
1364 1222 58122631
490 1619 691532618
521 1178 1045451500
1369 ...

output:

25
2
1
2
876064
607262197
8
26798
53
22
11
3723
36
13
2
1
1
123
140
258
0
14
0
3
4
0
0
37064
5
0
14
1
1
7
6
2
3
71
2
1
0
2
179186
3466
0
1533
1244
10
0
1
6566
3
0
1
10527058
0
1
1664
125195
1
352228
0
30
25
0
1
27
0
0
0
1
0
20
0
0
3
0
17855
598
6291
-1
0
0
22
499532
5
0
1
0
1
5
125
21
185
1250
0
0
4...

result:

ok 88905 numbers

Test #26:

score: 0
Accepted
time: 583ms
memory: 35472kb

input:

1949 2893
827 599 761799773
101 1942 175073640
469 1402 107959519
392 937 275420947
1370 83 65004451
690 1499 148665
1570 172 796293812
572 1674 807043920
225 1947 804706320
692 884 980218079
732 501 1066014698
1185 169 243664873
553 1561 328808767
582 535 1030254182
1028 1363 919333087
821 60 51699...

output:

0
3
0
25
117
18
14
3
1
55
7180
22144
2
2
0
1
2
53
4243339
900
3
0
0
92
0
0
12
6
8
0
12
24605
13
16
96
80
4
57
15
6399
1139580
7
18
18
0
2
0
231
52
334
2
1
82
6
14
0
0
1
12
142
0
0
2
2
4410
118351
256766097
3
14
1
3
0
1
0
2
76
1
35
7
0
2
0
1
1
7
0
0
31
4
3497
3
1319
8216410
7832
0
0
3
71
6
744
222
1
...

result:

ok 95745 numbers

Test #27:

score: 0
Accepted
time: 1192ms
memory: 65932kb

input:

43648 63543
11945 2045 920041601
27966 26466 328898197
30255 29633 243145769
25296 14836 914299691
34229 19957 501558629
19856 419 45409700
17770 13098 168470014
34919 40840 365738291
42335 38875 509714871
28743 24147 326112950
24364 4160 745278148
34799 27205 567647048
43257 42600 1059823537
25618 ...

output:

59
8
114
0
0
93
0
0
1
1
0
6
23012369
0
24
1
51
22
0
0
0
0
0
3
0
13958
8
7
1
204
3
0
0
0
34176
1
1
1
0
0
0
24064
35
113
0
10
0
9
0
9
1
1570
3
0
2
0
0
7
75
4
-1
37
0
0
0
0
-1
1
3451986
2
0
3
0
0
0
0
3
200
0
7881
0
3
30
5
5
756
1
0
0
12
83
0
6531
0
3
19
0
351
0
1
0
12941
0
1
0
0
1558
4
15
0
14
0
375
0
...

result:

ok 153976 numbers

Test #28:

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

input:

43648 64112
30772 42893 440139706
26267 16323 697588169
1288 38234 24738048
15902 2481 456095619
2704 7656 162081423
41852 27324 41002026
34204 26807 872265113
7214 35458 210843316
8919 20571 397798541
15081 27094 592733848
4434 33376 755083096
15367 14252 779349574
43599 10645 396415165
22032 20984...

output:

6
0
0
0
66
4
4
6
3
0
7
14
2
2
0
59
29254
0
0
887
1
105
0
5
6
1
1
1
-1
5
13
1012
8
1
0
0
7
2
0
1
0
23
3
7
2
718
15
508
1
11
0
11
0
82
0
0
0
0
7
127
0
0
0
22651496
1
23
221650
2
0
1
0
1
0
0
17
1
0
3
4
15
0
0
3
2
0
7
2
1
1
3963
3
0
12
0
0
14
0
63198
1
0
26
0
6
0
1
5
3
121
0
3
3
1
0
0
0
18
5
7
0
1
25
3
...

result:

ok 392 numbers

Test #29:

score: 0
Accepted
time: 600ms
memory: 61956kb

input:

43648 64767
5493 15820 697212372
40405 41790 333421757
42792 18039 486376940
24266 39038 315898778
5357 33576 794179219
19557 22162 3231443
20706 30319 231472978
21888 36288 663504083
33204 19317 14485796
2091 310 986142082
29214 2132 1018873509
7814 36124 103674322
13205 3219 927945025
17807 37102 ...

output:

2
1
0
30
1
7
4
0
1
0
1
7
43
0
0
102
7
0
0
0
0
1
0
30
0
4
143
7
0
1
1
9331
0
1
0
14
4
3
0
31
7
17
461
594
3
3
59
0
0
133
1
0
1
0
7
10
2
1
0
5
0
1
2
0
1
3
3
4665
138
1
0
1
4
17
2
0
217
12
7
2
2
0
171
10
7
6
6
87
2
0
0
7
0
5
7
0
0
0
75
1
94
36
212
0
0
0
6
3
0
215
0
1
24
5
0
0
14
112
0
0
3
0
0
0
0
2
137...

result:

ok 69305 numbers

Test #30:

score: 0
Accepted
time: 888ms
memory: 66148kb

input:

43648 65016
29785 28181 489588752
15919 5592 780797386
24374 18690 305590659
34567 14612 550455638
27370 5739 237781059
42066 29929 165392327
28205 15761 752867046
9700 22628 20052890
14827 31313 653673383
18794 43028 771426943
21512 15149 154176833
8532 29513 816463543
16313 6096 1012140991
23628 3...

output:

29
4
5
0
0
30
3
1
3
164
0
0
2
0
0
6
0
0
2
6
1
1
10
0
0
1
2
0
0
2073
1
4
0
27
1
3
12574
3
0
1
0
2
31
1
73
692
0
0
0
4
2
0
62
1
0
0
10
0
0
5
4
1
108
1
10
0
1
0
6
47
9
0
346
94
1
10
27
1361
1
3
0
14
512
0
5
29039
336257
0
3
3
0
0
0
2
30
1
0
243
1
5254
0
6
0
1
2035
18
2
0
1
1
41
9
8
7772
2
1
0
57
1
0
0
...

result:

ok 109887 numbers

Test #31:

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

input:

43648 65334
24840 4517 662586323
18455 23409 453669454
28789 4506 187814595
11295 26522 873410934
4541 33486 157064155
23437 14703 981431672
11755 20543 892666916
27185 15081 385649234
43022 41471 1073568125
15399 32351 549546270
38858 43604 535933755
16036 33218 577009067
22939 16654 325304044
4038...

output:

5
41
231
50
0
1
0
0
37
1
111
0
257291877
3
3
0
1786526
2
0
2533
14
0
0
1
51
0
123
4
0
1067
0
14
3
8
54
1
61
1
13
18
0
1
3
1
0
6
0
0
0
1
3
0
6
0
0
2
3
1
68179
0
449
1547
0
0
1
0
0
23
3
213
0
15
6
1629
0
0
4
0
5
0
9
1
0
15
0
14
1
0
17
0
140
0
150
1
0
0
0
0
90
142
1460
2
0
27
0
32
2
2
0
21
1
3
23
5
58
...

result:

ok 100387 numbers

Test #32:

score: 0
Accepted
time: 1760ms
memory: 101208kb

input:

100000 146408
15266 43523 895013290
32641 94498 743513041
81222 15245 948451207
185 51124 1056354735
15567 86706 746377659
26897 79036 92043756
40216 91986 878597755
94922 40867 889803451
93332 47267 713677717
49826 48605 332946335
58633 79476 51575043
29820 39767 825670019
25617 5806 119128371
739 ...

output:

0
0
0
3
6
5
1
211
0
8
0
0
1
0
0
2
26
0
0
209
0
0
1969
5
0
0
0
14
0
29
15
0
0
50
5
1
1
1
7
0
0
0
0
2
13
0
0
549
116
3
31
0
0
0
0
0
1
0
0
5
2
88
0
1
5509
3
1
22
1
14
2
0
0
0
7
517683714
4
0
271
800
127
3
1
150
1
11
5
3
7
213
0
0
42
13
4
46
0
1
0
3
0
9248
1
2011
2
618
40
211
0
13
154
302
26
6
7
820
117...

result:

ok 200000 numbers

Test #33:

score: 0
Accepted
time: 1718ms
memory: 99244kb

input:

100000 147459
1863 9923 295796986
57930 1136 240937121
16168 49228 30831737
19098 74104 337951459
12034 69516 777635754
99182 30090 163199088
6279 2889 1000830867
43969 66667 946157939
21770 85195 261091799
81458 31110 611682212
49878 47272 1018049805
64200 50155 170907937
47817 66360 932502014
9296...

output:

65
34
1
0
6
1
0
0
0
6
116
196
0
1
1
0
845
1
31
9
22
0
907
0
22848115
0
6
1
0
0
88
18
0
2
0
1
0
0
2
0
0
33
5
5
0
4
2
14708
0
0
0
2
34833
88
18365
0
7
0
0
0
21
0
4
1880
18
0
237
0
3
0
0
0
0
123861
0
14
61
0
0
0
187
0
228
10
0
0
0
0
0
4
14
1
1
1646
12180
4
0
1
1
0
196
2
0
5
1557633
2
5
277
0
19
1
11114...

result:

ok 200000 numbers

Test #34:

score: 0
Accepted
time: 1735ms
memory: 99536kb

input:

100000 148090
83831 91731 465451754
51767 66133 232674370
34510 76649 588273407
76587 62291 23074600
98357 1363 230137874
21234 18037 635675530
82545 17182 624526750
84631 90038 217764843
73883 9824 931366186
99107 48137 864091278
70476 44666 684366169
69367 34605 879222687
95348 81894 116391739
477...

output:

0
0
29
136
102
195509
915
8766
101
5
0
14
203
0
0
0
57
0
0
1
0
0
0
0
307
0
0
20
0
10
0
1
52
13
9
971
1
0
0
4
17
0
0
0
22
411
1
1023
2
3
46
4
415
6
0
0
1
1
1
2
0
97068
127
16
173
37
1
0
14
13
42
1
3
0
164
0
58
15
9
0
3
5
0
0
4709
0
365
325
21
0
267
1
0
35
0
0
0
0
5
79
867608
0
0
11
2
44
7
1
0
0
2136
...

result:

ok 200000 numbers

Test #35:

score: 0
Accepted
time: 1648ms
memory: 102796kb

input:

100000 148694
70677 62643 832575700
4392 20203 789041375
2373 7454 67217454
42511 32828 380327865
38033 62555 382796997
82727 53207 185798944
11241 79432 383069648
44474 20820 889174137
36753 69352 904256132
7245 48097 746191455
98042 19998 690980928
70977 13525 213523378
71930 73933 1049892362
5094...

output:

0
56
0
2
8
10
15
45
0
9
6
355
15
3
0
1
3
1448
188
0
0
6
0
4
1
0
1
10
3
1
17
1
61
3
6
55
0
11425
528
2
3
58411
1113
0
0
3953
1
53473340
4
0
34
1
3
363814
1
1
1
5479
2
0
13
910
3
6
0
0
0
368
0
0
4
1
15
15
375
4
1
1
2
13
0
0
0
51
10
1492
0
0
4925
4
0
0
1
1
3
75
0
0
5
0
26
1
0
6
7
6
1
145
1
0
158
1
0
0
...

result:

ok 200000 numbers

Test #36:

score: 0
Accepted
time: 1653ms
memory: 99560kb

input:

100000 148985
69511 81189 752873893
20339 17468 792295745
4955 19025 578261053
11824 87289 793407047
47818 52850 110248126
95045 89420 391745383
53915 61864 936270403
75566 14160 407827682
49485 12335 771879682
43121 65699 286162528
19555 47102 1042865266
25614 43581 54105574
32747 57900 794022019
6...

output:

26
9
1
2
810
3283
0
0
364
1
0
28
792
7
16
101
0
16276
0
2
0
115
0
3
0
0
12
105
0
0
15245
61
2
3
22
1
0
0
0
221
10
1141
49
58
78
1
112
1
0
0
3
18
1
332337
2
2
0
0
0
0
0
0
1
0
0
75
1
0
0
0
3
29
10
3
0
0
0
0
100
14
11
0
0
0
0
12
0
0
16
111
16
13
14
38
19719
38
4
0
0
28
0
28
0
0
1
0
463
0
85
72
31
0
5
8...

result:

ok 200000 numbers

Test #37:

score: 0
Accepted
time: 1667ms
memory: 104236kb

input:

100000 149379
91380 2526 565871020
92392 27067 942080682
9116 67575 178323043
41926 8389 869086537
9834 72566 228626742
55315 3592 51049255
38637 98038 77886033
63423 21299 677066785
90982 25769 880481115
54130 30200 743256543
38622 38096 569230052
28144 87526 9383062
48504 87276 752871136
33664 252...

output:

0
1
0
1
1
2
0
1
28345170
0
0
0
0
17
6
0
27
0
1
282834
10
0
5
19
0
4
0
1
51
3
1
97668
0
0
58
0
1905
0
8
0
12
14
0
2
226386
2
0
0
0
0
0
7
1
3
0
0
0
0
0
8
0
0
2
3
0
0
11
0
0
1
59
0
0
5
0
1
263
0
4
0
0
0
0
1826
0
30332
25
1
4626
7
3
16
506
0
163
0
0
29
1
2
0
30382
12495
0
334
0
3
4
0
61
7
1
3
13
0
0
13
...

result:

ok 200000 numbers

Test #38:

score: 0
Accepted
time: 1749ms
memory: 102216kb

input:

100000 149574
83022 7007 1042631037
10817 45703 882747384
50854 57284 411894372
30756 76288 64311267
64132 21680 709214727
22850 25941 209657308
54824 91062 241614085
67072 24512 765473865
8765 39399 895008342
33426 41412 757998290
82520 20457 682719394
61186 14952 86726058
32998 15020 76650468
6984...

output:

60
125
8
0
1
21
4
255242
3
3
0
0
244
15
0
6
21
1
2
22
0
112
0
0
0
52
0
694
0
21
0
1
41
14
2
0
22
9
28
7
35
0
1
24991
0
1
610
0
0
0
183
0
7
0
0
3859
41
0
0
692
2
2
3
226789
21
2
0
0
0
0
24
0
1
0
1
0
1661
0
0
0
2
227
2
3
1
15
236
6
7
59
0
0
9
7
7
30
48
7
41
2
43
11
0
1
0
13
8
0
0
2
5
38
0
2
10
3
7
20
...

result:

ok 200000 numbers

Test #39:

score: 0
Accepted
time: 1679ms
memory: 99816kb

input:

100000 149668
76916 17171 495893698
23250 31258 840162545
6979 93444 451469063
94689 11781 182750844
50093 62375 907991134
37433 38770 939746016
58356 59694 1041653466
13627 86281 944209030
13406 55793 511406434
69887 2133 306438061
65176 68496 893297031
72600 13578 688025868
43366 73819 73080219
13...

output:

0
3700
1
0
0
91
6
0
9
0
3
13
0
0
0
34
0
1
3
587
3
60
0
0
1
58
31
5
0
0
14
183
406
1
0
0
1
28
0
5550551
7
0
0
3
56
0
4449
0
3
3
0
7
1
0
2
2
122
1
0
538
0
2
58
1
2
0
11
8
0
0
0
21
19
2
114
19865
0
0
0
0
5
0
55
61
1
5
0
1204
0
40
0
0
1746
0
0
0
1718
1
39
0
20
0
79
18
0
17
30621
0
3
20
3
5
3
1
1
5649386...

result:

ok 200000 numbers

Test #40:

score: 0
Accepted
time: 900ms
memory: 97276kb

input:

87381 131070
10511 49759 601428703
68070 41172 889440287
71534 50759 613466283
5153 80104 812797761
68981 29714 19671417
49349 8810 711884303
72082 55799 792957444
39541 39391 11229128
584 19936 543888655
84832 8131 323394057
10451 13986 380532380
79370 41422 16193525
32409 81247 878988169
33833 478...

output:

168273087
33596903
545523665
478380434
705168390
336091140
412091542
270713874
471634655
26343048
136484741
679503962
203474075
104866840
219437206
21659726
206573229
277349279
148947008
273053978
541593618
499928655
604309612
34342250
268854613
815287301
-1
483166216
105138702
818024613
14949359
60...

result:

ok 200000 numbers

Test #41:

score: 0
Accepted
time: 893ms
memory: 91140kb

input:

87381 131070
84451 58955 1004450555
12977 78452 495674176
4322 54095 327119716
48881 74140 1015769339
11571 49579 318925169
48235 38653 314900899
81410 7889 368540706
9284 44192 693582049
67713 71520 288205437
43588 83524 271378742
37333 34197 289990182
85700 5122 645491247
42015 1439 527734680
7658...

output:

277634048
210865258
234882529
215260706
403048128
148115012
687443695
151322641
-1
537414912
916757462
486605830
164629840
21023236
109318511
436604933
71827651
136380557
626540765
138765321
289433600
203831493
39926630
143179786
285245725
201642012
210113202
486870307
739508507
-1
416073029
1342457...

result:

ok 200000 numbers

Test #42:

score: 0
Accepted
time: 165ms
memory: 31752kb

input:

5 6
3 4 624192582
2 1 428225646
1 3 695894075
1 4 206498941
5 2 555890342
1 5 950272712
200000
4 2 590
4 5 1
4 2 2
4 3 12
1 5 48
3 1 6
1 5 1
2 3 1
2 5 1
4 1 1
3 1 13
4 1 16
3 1 1
3 1 1
3 2 5
4 3 51
3 5 66
5 4 1
3 4 50
5 2 4615
1 5 1
2 4 3
2 3 4
2 1 1
5 2 1
4 2 1362
2 4 17
5 4 1
2 4 1
5 2 21
4 5 160
...

output:

-1
887811765
-1
-1
-1
-1
950272712
821867605
555890342
206498941
-1
-1
695894075
695894075
-1
-1
-1
887811765
-1
-1
950272712
-1
-1
428225646
555890342
-1
-1
887811765
365484051
-1
-1
-1
624192582
887811765
-1
-1
-1
-1
-1
555890342
-1
-1
887811765
-1
-1
-1
-1
-1
624192582
-1
299795187
-1
-1
-1
29979...

result:

ok 200000 numbers

Test #43:

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

input:

5 6
1 2 915854645
3 1 676332940
2 5 323338322
3 2 516346043
2 4 464803983
5 4 150051037
200000
5 3 2
5 3 2
5 4 13
5 3 1
4 2 10
3 5 1
5 4 4
5 4 1
3 1 53
2 1 3
4 1 1
4 2 1
1 5 14
2 3 8
3 2 37
2 4 6
3 4 43
2 4 140
2 3 2
2 3 908
4 1 59
4 3 119
3 4 16
4 3 1
3 1 92
4 3 1
2 1 5
4 1 1
3 5 1
4 2 20
5 1 1
2 3...

output:

226693355
226693355
-1
226693353
-1
226693353
-1
150051037
-1
-1
757239224
464803983
-1
-1
-1
-1
-1
-1
516346043
-1
-1
-1
-1
91392052
-1
91392052
-1
757239224
226693353
-1
634590565
-1
150051037
516346041
-1
-1
-1
-1
-1
634590567
-1
676332942
-1
150051037
-1
-1
-1
915854645
-1
757239224
226693353
46...

result:

ok 200000 numbers

Test #44:

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

input:

21 30
17 5 1044152392
18 21 45137651
19 1 680155341
14 11 433613087
19 11 63162495
19 5 345110406
18 2 1066510666
2 9 1048565527
15 4 318189677
10 9 651065220
7 19 666775724
14 13 479320519
8 14 730755397
6 16 270102816
13 8 924821679
6 12 754723545
12 16 1021664249
6 3 608819977
14 15 35145204
10 2...

output:

456774354
-1
247420928
-1
-1
111728274
792650278
-1
1044152392
-1
1064307157
906081388
216942149
-1
537024472
-1
983171794
808736731
-1
848427437
611591628
1000771029
32407133
520795600
807085816
1030466825
129787716
-1
974780088
-1
603307092
983171804
412188164
1021664249
555754573
603307092
639157...

result:

ok 96761 numbers

Test #45:

score: 0
Accepted
time: 515ms
memory: 47588kb

input:

21845 32766
13582 6119 730044657
20441 12182 430130054
384 19508 734883838
2462 14098 987669071
7828 21215 130338708
12558 15874 592209566
15795 4219 1066562345
9082 16981 939799677
7718 4325 357949696
7243 3380 832632990
17260 366 817544255
9804 2355 1011355867
17131 20836 234801445
8862 4679 94813...

output:

218628152
889497892
809553164
268640494
208399075
594790389
966298882
551603403
352617473
406850249
84967661
638376284
181046144
579751304
138413076
495321152
411832459
201675622
940504281
203723086
205543825
583284204
578816001
604054845
361301079
566956147
68715081
30483689
872708726
-1
67422404
9...

result:

ok 171780 numbers

Test #46:

score: 0
Accepted
time: 1778ms
memory: 106380kb

input:

100000 149998
68616 99674 898407772
36317 39648 52698678
65101 90735 1068956995
8158 42796 1035088621
95845 82432 110778349
53772 39345 869431981
38817 53583 915402343
26012 65472 804692931
76732 18251 676963868
4815 57909 581278402
97621 63454 669642973
56510 88773 726601245
654 19687 584104709
625...

output:

2686
1
12
0
0
3
9
6
0
0
40770
1
1
1
2
3
1
1
111
10
10
11
7
118
213
9
1
48
1
165644
0
36
1
0
0
8368
21
22
3
2
1
1
7
5
2
0
1
7
5
23
6
193
9
1
1
5
43
19023
150
1
3
28
1
7
12
15
7
0
7
129
0
24
1
15
47
18367
1072
0
1
10
0
29
4
48939
1
2
13
1
9
3
66
936
1
5
0
38
3004
6
0
1881
6
0
3
1
0
2
4
8
51
0
1
18
0
4...

result:

ok 200000 numbers

Test #47:

score: 0
Accepted
time: 1817ms
memory: 108376kb

input:

100000 149998
10561 4980 887987654
53453 35341 253437624
24064 14112 329588055
73378 13586 756701224
18788 46484 804267435
56194 88715 809407967
12632 12555 450181695
21968 28046 733937144
71898 15178 544700706
63808 35492 16354034
9173 99648 984053129
65712 20661 1058020776
26205 97950 476146323
55...

output:

1
0
0
19
5
2
374
129
1
1
42
1
7
5
117
10
7
61
1
2
2
0
1
0
17
4
6
985
2
0
3
141
6
14
29
11
6
0
0
1
0
61
6
1
13
19
0
2
3
1
3
53
0
27
4
318
5
42
3
3
3
0
2
358
0
46
2
12
3
5
0
1
0
7
7
180
57
26649
20759
30
1
1
65
3
1
3
0
1
205
195336
0
259264468
103
9
1
7
1
1
5
0
0
3
0
41
2
0
3
0
2559
62
3048
0
0
1932
8...

result:

ok 200000 numbers

Test #48:

score: 0
Accepted
time: 235ms
memory: 34184kb

input:

19 27
18 3 816291864
7 6 27639275
2 7 205012875
3 13 226503954
17 18 362488697
2 12 673499526
16 4 360506102
17 4 485261281
16 9 741140698
15 14 419495461
4 1 1056877652
1 17 262595734
10 3 493244077
3 17 75475611
6 2 587738120
9 15 693619096
8 10 884019998
19 15 758172477
2 11 848183646
9 14 897355...

output:

283534271
-1
15409433
-1
902668137
-1
-1
57955786
-1
469606100
215189710
-1
8667860
131521149
680589
-1
-1
102068953
-1
178239584
-1
-1
-1
25832868
-1
-1
226503954
-1
815318841
-1
-1
-1
8451756
780631
157635923
101285738
-1
80648946
238763061
-1
-1
-1
121072946
-1
-1
848140894
163579609
243344824
-1...

result:

ok 200000 numbers

Test #49:

score: 0
Accepted
time: 205ms
memory: 31488kb

input:

17 24
4 10 808072679
6 12 325374847
12 9 532076933
8 16 820130365
9 10 20360644
15 12 521816264
11 1 160966291
11 8 185077526
6 14 1051142779
17 8 881320288
5 16 1069330264
8 5 750844877
2 10 199888304
9 4 426679023
1 7 598854891
14 12 588605391
13 7 1070523704
11 17 969554546
10 13 242225625
1 13 1...

output:

6072712
60077799
124539348
156422733
11899840
711516470
87026030
717354794
144350772
684120039
-1
-1
-1
-1
-1
12024465
133293264
64633509
-1
152295683
234179067
-1
1069330264
199888304
257858917
162280432
8166813
52680496
65226010
-1
443121605
148545685
2516639
129424133
469327713
-1
-1
552800826
15...

result:

ok 200000 numbers

Test #50:

score: 0
Accepted
time: 795ms
memory: 83104kb

input:

66542 99811
49090 25471 13965806
4651 15046 424751776
25108 19256 166113829
34602 3842 214954200
29583 4406 514302369
11612 19006 8160143
32360 35988 184521189
57606 8311 754097635
39779 8549 940410010
3972 59032 834137475
1481 39692 841743359
5498 33156 297928447
64000 47201 396181702
18358 11247 8...

output:

1
72
1
2
1
112
0
23
7
104
2
10
29
2
29
4
293
144
313
36
12191
3
3
1
45
45
14366
0
20
3
2
3
1
0
2346
0
397925
5
4
36
1
0
47220
143
9
256
161
7
15
3
28
110
7
2
33
1809
11
1
29
3
21
12
2
1622
3
14
0
119
2
1
3
62
3
8
7
32
415
184
14
15
5
0
96
58
86
6
66
1542
2
24
55
2
0
8
4
625
38
803
131
6
15
2
1
6
2
1...

result:

ok 90643 numbers

Test #51:

score: 0
Accepted
time: 381ms
memory: 102480kb

input:

86821 130230
86354 35241 40676672
31972 42796 941953404
26860 75254 1014463670
18418 6769 583192941
30692 79343 136718131
85343 57146 691587133
81148 14618 890142872
5253 28628 1033310859
55105 53960 94658689
54666 66797 551628409
61521 31583 570920142
4404 72701 885449675
47512 63209 670042332
7460...

output:

229
0
2
24
11
32
22
62
32
364
13
780
37
87
39
38
33
4
227
0
59
324
222
32
0
0
4
32
12237
32
246
39
27
0
0
33
2
2473
42
47
10
34
1464
32
39
32
1
32
39
202
38
3
32
0
0
11
0
126
103
15261
0
3
14
0
393
32
23631
32
32
7
5
36
596
39
32
60
32
66
11701857
228
33
38
6
5
7455
48
32
119
63
32
0
32
2
32
32
0
32...

result:

ok 20550 numbers

Test #52:

score: 0
Accepted
time: 1838ms
memory: 108980kb

input:

100000 149998
43592 82107 133642904
88539 675 792100149
69232 30940 288863316
25168 19791 233293289
59096 25380 1021824131
9969 38134 617247763
35996 3098 444731041
98589 11376 658140943
83280 17997 961762466
84838 13894 301669539
28532 13461 211440213
55869 92992 58409421
16090 54686 632402974
1262...

output:

0
39
50
2
2275
0
0
14621355
127
0
27
44
69
14
15
3
1
2
685
170
0
0
0
2
1
233
337
14
14
123
11
25
30
92
1
1
0
18
28
2
2
0
0
2
0
1
11
1
2
0
3
16
2
2078
1
14
2
0
3
0
0
881
0
400
0
11649171
26
3
15
30
1
20
127
0
0
16
1
1
6
0
6
14
553
6
2
153
116078
15
9
1
14
1
93
25196
30
1
0
1
745
0
1
0
7201
2
193
12
1...

result:

ok 200000 numbers

Test #53:

score: 0
Accepted
time: 1694ms
memory: 112388kb

input:

100000 149998
76670 59129 1024811264
73931 41783 34817388
44753 81016 190896031
917 93351 571576149
71279 33781 460729545
11342 76826 779755814
76954 82610 769300328
94475 7480 65588744
20998 7282 1043830661
50585 6468 39706912
83193 71313 306454560
60203 81917 914556115
8087 67233 367412485
98429 7...

output:

4
16
0
11
14
1
0
4
8
1
4
6
58
2
8540
7
1
-1
84
5
5
0
0
14
232
0
47
15
5
53
631
5
7
7
41
2
4
0
15
0
4
1
7
94
8
23
0
5
11
6
7
510435
6
190
8
28
70
57
4
0
15
0
14
7
75
5
8
7
6
16697
6
5
3067
1
6
0
5
4
5
1799
12
165
5
3936
0
0
221
1
0
70664
74
350
13
14
286
10
33
246
25
5
8
903
24
5
29379
2
1
1
2
1
931
...

result:

ok 200000 numbers

Test #54:

score: 0
Accepted
time: 235ms
memory: 31916kb

input:

12 16
11 10 937947315
7 8 228137790
8 9 586881613
5 6 1044836176
8 1 843216550
2 7 145882181
4 12 835018181
7 1 390338400
7 4 599558111
3 6 394720138
9 10 942187358
3 5 1008922384
8 10 335499907
4 2 1068150672
10 3 76442517
3 11 210345076
200000
4 2 1
11 3 1
3 11 4
2 7 1
9 4 1
3 8 2
2 1 1
2 7 1
3 9 ...

output:

722303898
210345076
-1
145882181
99773756
509465222
189939503
145882181
-1
130076134
-1
295311728
-1
-1
-1
250453044
-1
396167210
315903730
14841216
250453044
471214159
516964889
106982494
-1
125394000
808408255
-1
189354386
390767149
-1
80782053
214448544
256603190
-1
-1
98882096
978895532
11521588...

result:

ok 200000 numbers

Test #55:

score: 0
Accepted
time: 208ms
memory: 32472kb

input:

18 25
4 5 807212435
11 16 948755909
7 5 406282221
17 6 803614666
2 11 767934908
8 13 860240786
10 11 529181727
8 18 981489268
5 3 518424969
12 15 949997247
5 9 941947365
3 4 81387582
6 2 833139403
17 2 902339827
18 13 340116856
9 7 230285258
16 2 127648476
1 3 49730373
12 7 214907113
7 15 996905631
...

output:

317124220
17566441
781801019
-1
22664066
579188292
-1
-1
784700172
36495914
-1
105321853
-1
313378289
472313063
-1
200221416
-1
44050877
6197293
-1
512862354
-1
744187471
-1
8923595
5987559
94544130
-1
339955806
43971907
-1
15143764
125149405
47597779
4908596
-1
-1
-1
387958745
-1
290357966
6197293
...

result:

ok 200000 numbers

Test #56:

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

input:

22264 33394
10477 4311 1004044564
10342 14528 543391612
10594 20547 327332465
4003 9720 359824005
20367 21741 1024019054
13895 10061 1039946905
14015 7218 729829848
18413 10888 205238555
11787 1290 547224669
12667 11854 818120008
18003 14490 267796168
21835 19897 1071460758
4391 12280 318794964
1629...

output:

38
1
428023
1
1
19
55
0
0
12
7
11
6
35
105
7
35721
12
15
0
457
28
97
1
1
18
4
1
6
1
105
248
1
13
92
21
12
1
1
5
68
57
12750
3
3
7
5
0
7
0
14
5092
3
0
9
0
1353
1
10
1
10
2
3
1
1
45
1
350
622807
38
1
1
890
1
125
4
1
14
0
1
12
0
212
0
21
25
6
1
7
2
9
2
1
4
225
862
0
1689605
1
25
1
417
1
290
0
27
8
2
12...

result:

ok 63149 numbers

Test #57:

score: 0
Accepted
time: 985ms
memory: 71944kb

input:

48737 73104
43355 46167 18344588
21774 46306 927416622
34007 31266 735847573
48438 17871 497442591
46107 39740 483275517
47768 567 325308983
30803 24582 639380628
33794 18620 572638209
5604 19457 151942999
46668 1906 718796942
2749 46325 313083776
47731 37024 491108732
43369 25218 472820908
24831 13...

output:

2
4
-1
0
21
340
9
7
24
425
8
3
14
5
2
7
9
1
11
4
0
5
0
7294
46174
1
15532
0
1
6558
5
13503
2
1
19
1
1
35
29
1
12
24
0
4
1
131
0
6604
6
0
28
18
14
6
2
7
30
5
6943
3
6
3
3
4
15794
3
13556
1
20
3
48
3
1780
251
105
867
20
60
3
0
146
1
7
4
30416
29137829
4
118
0
1
195
3
6
1
116
6
0
2
12
17
123
8
7
0
2
0
...

result:

ok 126283 numbers

Test #58:

score: 0
Accepted
time: 1697ms
memory: 117336kb

input:

100000 149998
48140 68326 25967150
47073 18014 817988782
88134 25810 30805548
99293 76496 592177082
32290 73816 814177043
19331 51562 796706962
67889 426 1017022535
68394 6671 411277383
97162 23099 796376284
84182 39621 703046602
87861 98777 644391589
6864 4929 803277227
49403 61367 70785967
26820 4...

output:

536870944
9673
216
0
0
9133707
0
3
0
2
30
3
4
0
2
42
0
0
1
6
17
0
31
322
1
29
6
4
7
9
58
2
3
536870924
63
0
5
24
638582992
5
3
0
2
1
268435457
10
134217728
0
71445
8
536870912
0
2
536870914
0
0
0
21
122
6
6
461
0
268435457
2
4
0
0
2
14
268435460
0
18
536870920
536870963
0
3129
0
1
0
7
3
6
0
5
0
2
80...

result:

ok 200000 numbers

Test #59:

score: 0
Accepted
time: 1656ms
memory: 108800kb

input:

100000 149998
2283 5206 964568738
80939 66338 235468116
88716 3397 355241688
4421 29948 176142722
56574 31766 72617030
73837 41309 369801431
79612 4765 219214144
94308 26014 793844028
41895 14018 37534018
99332 21711 889768806
63376 33632 155213217
95040 33631 730733286
77377 67772 419980502
58531 3...

output:

15
0
0
58
0
1270238
268435464
2
0
1
1
16777216
1
0
55
2
0
0
1
0
149
7
0
11
0
285
41
7
55
8388669
0
135
7
0
0
2
0
884
5
3
0
17
13
10
4
10
0
4
0
26
134217729
0
1
0
348
0
3
4
13
20
383
20
0
0
213
0
682320
0
0
0
3
7
0
0
0
20
0
3284
24966
5
0
6
243531826
0
0
2
0
1
543162371
1
2
7
0
7
0
0
1
1
1
1
0
0
0
1
...

result:

ok 200000 numbers

Test #60:

score: 0
Accepted
time: 225ms
memory: 31616kb

input:

15 21
1 14 527161112
15 5 163738538
13 11 904972076
5 2 27386382
15 8 482061159
4 11 34468333
1 3 514414134
13 1 497777579
8 9 935176820
2 12 676895791
12 6 895386085
4 9 73488990
5 12 704216628
14 3 29524270
8 4 870117417
12 10 472392466
7 4 235228312
10 6 695640823
1 11 677100695
7 11 201899381
8 ...

output:

73488989
681600124
22616671
-1
-1
-1
257709764
293176364
69322488
412773773
-1
677100695
-1
979487904
540741023
-1
273979976
-1
-1
-1
349715138
119794533
165553929
307901352
140743076
-1
1007890060
-1
-1
514414134
497777595
972585545
349715138
615045384
-1
335270304
-1
293176364
-1
326399424
3079013...

result:

ok 200000 numbers

Test #61:

score: 0
Accepted
time: 211ms
memory: 32752kb

input:

20 28
15 13 694517195
9 3 490217843
15 6 348147659
2 5 241241721
3 14 73110360
4 16 653216754
9 8 761333349
15 8 115637111
1 6 644378076
17 8 972007823
18 9 648738333
1 15 849879575
3 18 999479150
19 7 657256312
8 13 796985021
11 2 227267360
3 20 33981081
5 11 65723737
14 16 569239679
14 20 10676268...

output:

578622378
122441378
-1
-1
-1
-1
117613453
-1
792916860
-1
-1
-1
-1
608892612
968494428
1060756443
1070154806
1007743808
-1
200841800
-1
229790820
-1
-1
-1
544969010
786812153
196507494
-1
279613864
-1
1069787459
980310668
-1
344895479
-1
248217612
228952968
-1
-1
937100069
509677990
-1
853987109
228...

result:

ok 200000 numbers

Test #62:

score: 0
Accepted
time: 1225ms
memory: 82016kb

input:

64577 96864
1117 6815 43594229
49420 52602 1034010406
1284 17881 345592520
41650 5379 937680183
3055 35163 398778032
27751 43837 205340735
38359 9134 1041446231
61796 63527 523932391
23254 30438 295878553
52449 51030 558514786
54096 22393 806155943
9110 41740 407493904
15931 3192 714704576
19883 290...

output:

318767104
553648135
1
28
7
0
943718403
820
0
4
319
3
536871154
33554438
7
6
0
0
7
7
25
0
939524096
0
1
268435514
5
3
28
33554434
231
0
35
407
5
0
872415233
97827934
385875968
541065219
783978
54
20
75497472
499384320
0
31
0
226
43
214
7
0
31
108
85065728
0
0
15
15
2
0
910163970
0
536870912
4
73
1
53...

result:

ok 167315 numbers

Test #63:

score: 0
Accepted
time: 700ms
memory: 73064kb

input:

50940 76408
1356 13059 592187710
9637 48491 118602222
31221 29463 853868596
43730 3601 603082799
33778 1417 957467996
45742 38596 184798868
39175 27159 463902344
42157 23852 303828660
36242 9496 765782949
31515 23514 195484801
35561 9050 81577536
35745 42033 371542240
20904 13337 970590535
47695 106...

output:

0
4
254474
11336064
52
0
3
553648130
13
0
0
121
0
0
0
1
0
271
0
26
754904
0
19
14728
12
8
7
105
0
301990128
2097153
0
7723
824266753
389120002
2
1
606208000
589992419
248
363
46
0
158
1
1
0
1
15
1
1
15
0
5
2860
0
2
1
3985
0
39
1
1
1
0
3
0
119
1
42663982
4
66
0
974127104
1
12
24005696
0
10
225
24
238...

result:

ok 100375 numbers

Test #64:

score: 0
Accepted
time: 592ms
memory: 139152kb

input:

100000 99999
92969 67188 560847985
31473 79140 907310470
37451 54639 722701699
58138 4609 604638583
36055 12034 783311714
62470 8457 139645666
91846 2444 317842186
55899 92403 506662164
49778 5224 19676452
43812 18222 473383141
33239 91197 844642081
7660 10034 657485605
72452 3123 80990176
10273 652...

output:

-1
481994158
-1
-1
-1
-1
-1
-1
-1
249112746
745590622
-1
-1
-1
-1
-1
-1
970996824
499297670
557079727
-1
-1
-1
-1
-1
-1
-1
-1
1066359184
969989878
-1
-1
76868280
113400993
-1
913558315
181975408
-1
-1
978893921
-1
-1
-1
-1
240417347
582902421
-1
-1
54831846
-1
-1
230880346
-1
37858538
112423451
-1
6...

result:

ok 200000 numbers