QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#134671#4272. Phone PlansKoD#25 ✓433ms81664kbC++173.1kb2023-08-04 13:52:112024-07-04 01:16:35

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 0ms
memory: 3604kb

input:

6 4 4 9
1 2 1
2 3 2
1 4 3
3 4 4
5 6 40
1 5 30
2 6 20
3 6 10

output:

33

result:

ok single line: '33'

Test #2:

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

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #3:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

2 10 10 1
1 1 915886339
2 2 430624192
1 1 879808770
1 2 577221915
1 1 439429731
1 2 304911826
1 1 148009333
1 2 51122687
1 1 558282772
1 2 421196385
2 1 436692145
1 2 654020563
2 2 162573477
2 2 989531779
1 1 646687051
2 2 549037477
2 2 699532275
1 1 679375858
2 1 83352965
2 1 415698228

output:

51122687

result:

ok single line: '51122687'

Test #5:

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

input:

2 10 10 1
1 1 1000000000
1 2 1000000000
2 2 1000000000
2 1 1000000000
1 2 1000000000
1 1 1000000000
1 2 1000000000
2 2 1000000000
1 2 1000000000
1 2 1000000000
2 1 1000000000
1 2 1000000000
2 1 1000000000
2 2 1000000000
1 2 1000000000
2 2 1000000000
1 1 1000000000
1 1 1000000000
2 2 1000000000
1 2 1...

output:

1000000000

result:

ok single line: '1000000000'

Test #6:

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

input:

2000 0 200000 1199833
636 1231 120395621
689 1640 497332138
1861 1980 798839749
560 1283 560726905
1332 328 431171189
1203 1764 466367210
1102 347 317109768
1462 789 761470540
350 1093 551905741
1718 1047 548650524
51 546 56733461
58 1519 744207013
826 956 943929583
1969 207 238061756
99 47 99683567...

output:

9768257

result:

ok single line: '9768257'

Test #7:

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

input:

2000 200000 0 1937051
1325 1770 628367155
105 1670 728177982
358 778 959944062
826 1691 651665248
1119 1906 382208628
1684 1232 677646622
807 265 902880211
1685 1660 405567549
1853 1982 988679307
1241 1054 385406922
862 1049 356441384
1837 673 443580113
1082 1795 738355567
1703 663 221254144
1792 84...

output:

20263921

result:

ok single line: '20263921'

Test #8:

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

input:

2000 200000 200000 1999000
1303 1065 135024256
1400 1409 157921645
1208 515 422761224
466 1398 267944161
40 1202 560552418
722 1817 773826339
1022 1534 720452215
1512 200 145291518
538 230 98848391
434 529 911575234
470 1050 103133355
1800 351 180303134
1527 1871 779519820
258 1872 279904732
1 512 4...

output:

1999

result:

ok single line: '1999'

Test #9:

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

input:

2000 200000 200000 1999000
1566 1720 828051227
411 209 634755980
293 258 80524979
1149 1694 253684780
71 597 899974207
1934 440 11614281
1846 870 794303074
800 1090 576722282
1022 1619 486756658
1135 1004 589873220
1300 326 565865513
114 341 308227260
310 134 735603010
437 291 714079414
930 1131 136...

output:

1999

result:

ok single line: '1999'

Test #10:

score: 0
Accepted
time: 83ms
memory: 6300kb

input:

2000 200000 200000 1999000
1505 1008 194848918
955 1466 251380587
306 119 329528655
1072 1067 684468438
1798 755 822161204
1475 1987 886864916
609 790 525637795
1937 1639 534864650
63 792 948290690
1282 553 998185081
1995 243 367638087
1517 982 238895274
1891 358 612397768
229 1599 453255817
200 115...

output:

1999

result:

ok single line: '1999'

Test #11:

score: 0
Accepted
time: 87ms
memory: 6544kb

input:

2000 200000 200000 1999000
888 998 519088944
896 217 366603047
963 1703 281897731
1419 1583 296352197
318 1644 449932680
1252 683 299241251
1763 1736 16908823
400 673 940814267
1864 1654 16539370
21 1360 526031095
320 1052 879613936
383 555 433309121
243 869 603865861
567 236 829646077
1057 1138 545...

output:

2000

result:

ok single line: '2000'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

2000 0 0 0

output:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3752kb

input:

2000 0 0 1

output:

-1

result:

ok single line: '-1'

Test #14:

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

input:

2000 0 0 1999000

output:

-1

result:

ok single line: '-1'

Test #15:

score: 0
Accepted
time: 83ms
memory: 6340kb

input:

2000 200000 200000 0
584 721 144517612
1593 1184 19655376
572 91 267489352
441 830 206284803
326 901 399207297
1220 164 270714861
1760 1765 242123575
1341 1187 778391819
247 104 618482901
1650 876 469853007
1338 660 237312298
593 1856 254405769
477 1212 387844191
603 1896 336160240
1397 444 77343103...

output:

0

result:

ok single line: '0'

Test #16:

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

input:

2000 200000 200000 1
1961 656 558726882
677 479 191436128
1411 291 100142168
932 1506 28223846
1264 1394 780504516
1276 1479 56569386
1363 65 480245792
1598 78 760054359
78 36 593906829
1112 535 999996793
1792 953 155333434
149 239 901391869
791 1800 803139774
1856 629 626568419
1931 779 330675974
8...

output:

2823

result:

ok single line: '2823'

Test #17:

score: 0
Accepted
time: 88ms
memory: 6420kb

input:

2000 200000 200000 4
1165 1872 797718594
1169 1055 624587802
866 899 658187098
1376 1679 853872729
635 1186 401602136
1058 241 170579264
1988 1953 539060919
1695 772 816154776
1551 1453 798051114
1678 810 856500252
637 1519 373040351
1663 1237 499974912
1222 174 950339946
952 1956 666630512
1053 17 ...

output:

13422

result:

ok single line: '13422'

Test #18:

score: 0
Accepted
time: 87ms
memory: 6420kb

input:

2000 200000 200000 51
825 28 972433150
472 1380 981558124
178 1129 462887818
496 1916 874585551
1806 1093 459363528
853 1063 835229701
1473 1816 509538236
1762 139 445678501
600 826 116492230
1924 1426 768569961
1093 802 138198370
1285 101 612512942
1696 527 863059072
1729 1091 238488099
1799 1725 9...

output:

207785

result:

ok single line: '207785'

Test #19:

score: 0
Accepted
time: 93ms
memory: 6356kb

input:

2000 200000 200000 346
479 1073 12925746
1739 528 708374552
1669 1597 187841053
420 1886 665883774
264 1753 39508213
1618 1695 153537785
734 950 163927318
946 639 332538805
1151 821 988862824
981 1265 633217016
1627 199 830812032
116 579 44204899
511 403 764449881
1828 538 469036862
953 1145 6928974...

output:

1325200

result:

ok single line: '1325200'

Test #20:

score: 0
Accepted
time: 83ms
memory: 6628kb

input:

2000 200000 200000 7700
1618 867 271795108
1951 151 702948614
463 231 446592273
882 479 999691562
1160 1496 458774157
862 177 365391789
1483 1529 152692222
1086 1926 981642023
650 1846 36577190
1541 1521 287755177
1549 145 326097587
1355 1965 846861888
968 1069 919410456
557 6 666217744
499 1453 429...

output:

4833174

result:

ok single line: '4833174'

Test #21:

score: 0
Accepted
time: 88ms
memory: 6564kb

input:

2000 200000 200000 10274
427 1831 50634939
924 761 973624360
1716 77 896823723
1770 286 368244715
281 1652 693233017
782 982 856834549
1990 872 586803005
1104 545 550493462
438 75 19630828
1939 95 811185364
1691 325 517180701
1832 1560 781228281
687 1611 15723447
651 73 423147727
1750 768 923943157
...

output:

4715135

result:

ok single line: '4715135'

Test #22:

score: 0
Accepted
time: 87ms
memory: 6404kb

input:

2000 200000 200000 353724
828 1686 612966370
1332 36 325102273
50 1233 839762664
1389 740 256158152
640 18 76640380
1324 508 966364428
1791 314 236880043
1092 1586 81535148
602 1178 352534909
640 1224 733613612
970 297 526950089
1654 1677 277859934
1583 1933 511147393
56 1854 778804499
1051 17 52473...

output:

6546895

result:

ok single line: '6546895'

Test #23:

score: 0
Accepted
time: 87ms
memory: 6336kb

input:

2000 200000 200000 1999000
1499 1526 627651931
378 1689 609556194
1326 237 371224081
98 527 251964139
1280 1750 293612965
905 1848 881495354
1870 900 902279678
1496 267 634703468
59 800 164035702
109 1934 882309468
1966 702 519776748
1020 666 951531959
385 850 241053535
1211 255 903671592
66 1285 65...

output:

34222040

result:

ok single line: '34222040'

Test #24:

score: 0
Accepted
time: 89ms
memory: 6588kb

input:

2000 200000 200000 0
1820 354 521259580
1799 1723 883151663
1892 479 590713896
748 499 454440477
1752 334 983007379
56 69 157027005
554 112 225804047
1680 600 279675368
36 1372 868160579
1988 1586 523730820
35 1704 39797544
117 1627 846004390
354 1056 280474791
1736 1676 249305541
1269 111 692287711...

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 92ms
memory: 6632kb

input:

2000 200000 200000 1
1787 1732 413014305
1909 217 339214620
519 1338 435678958
883 831 44937921
1912 970 736120426
1190 1219 718941669
1216 1909 109658172
1849 1869 686616094
301 965 677802187
445 724 195098678
1306 1951 299168831
1970 262 204353384
1220 1409 504375659
1713 623 754436498
1452 1620 5...

output:

2

result:

ok single line: '2'

Test #26:

score: 0
Accepted
time: 88ms
memory: 6564kb

input:

2000 200000 200000 4
402 1914 269682654
675 1436 291439604
193 370 988082031
1849 1502 691456540
883 665 492038489
28 1266 573600132
1656 352 680334585
1668 1039 911608739
157 1752 964298632
979 19 526980
1113 504 262870788
126 541 220684410
269 1031 721802318
1900 1999 328920840
1770 641 692254361
...

output:

37

result:

ok single line: '37'

Test #27:

score: 0
Accepted
time: 84ms
memory: 6376kb

input:

2000 200000 200000 26
526 1621 483988447
1703 1932 686404766
1111 1245 624032004
1457 1671 886702864
409 957 385143382
1928 1503 977317507
1319 349 983715228
401 30 251459110
245 1355 563161269
459 1436 965861604
679 949 983070365
1692 1261 456157217
698 99 409820975
1528 1362 963977301
1295 1852 79...

output:

25

result:

ok single line: '25'

Test #28:

score: 0
Accepted
time: 87ms
memory: 6416kb

input:

2000 200000 200000 625
728 133 344090289
1062 1880 597135161
844 1495 874100306
1930 389 490213163
1783 724 571192863
1499 1894 866097805
325 687 79859122
1674 1747 563976487
1940 60 855240336
1516 1087 431861062
1314 1217 250576340
646 311 63874546
647 1552 870943884
1535 1190 223697
345 1186 65344...

output:

39

result:

ok single line: '39'

Test #29:

score: 0
Accepted
time: 88ms
memory: 6628kb

input:

2000 200000 200000 4700
1725 821 429457120
1764 490 903325799
660 1294 347283520
325 16 253789876
464 1258 168173237
80 660 57504741
1136 1316 769617858
1767 1394 287008686
1824 1206 820352296
114 330 965781020
140 223 885989447
1458 742 932496684
762 1574 655017664
1598 596 723299463
1213 1898 5236...

output:

84

result:

ok single line: '84'

Test #30:

score: 0
Accepted
time: 89ms
memory: 6336kb

input:

2000 200000 200000 88061
668 1817 402362288
1250 696 637044070
1793 1147 890609254
1839 671 427058014
1636 51 777111988
567 359 308999615
1552 1510 40834395
1566 1311 738132782
271 1975 807983143
998 82 633239353
1096 843 454384442
102 1427 218117173
329 227 915637054
685 1727 911188324
1330 1175 94...

output:

652572

result:

ok single line: '652572'

Test #31:

score: 0
Accepted
time: 87ms
memory: 6420kb

input:

2000 200000 200000 533113
1338 1754 782883635
1349 1488 592703188
1645 1448 477986692
733 1042 47
981 1720 461041447
263 452 26372078
1812 765 384744847
205 372 507702235
12 1369 191909928
288 1600 812952698
1238 762 715972252
912 1876 653427552
974 1617 941376898
43 1554 514299614
220 1772 58179883...

output:

1962115

result:

ok single line: '1962115'

Test #32:

score: 0
Accepted
time: 84ms
memory: 6344kb

input:

2000 200000 200000 1999000
713 984 491810215
23 1495 711013830
1680 304 483176300
121 1907 948073782
176 89 573161170
1928 609 583837234
736 990 511532333
1734 1850 807407784
821 1402 566288558
1818 835 317847108
1824 126 439452972
1585 467 46541223
775 1709 549038510
1487 205 239467439
1096 1794 38...

output:

31758367

result:

ok single line: '31758367'

Test #33:

score: 0
Accepted
time: 90ms
memory: 6156kb

input:

995 199991 199994 128256
177 82 677669502
416 854 677166289
543 794 364534270
680 242 8
760 186 900225249
875 563 337492994
732 766 894982532
114 483 4
259 885 8
954 157 590392390
308 566 1
37 871 633804510
606 410 916672224
125 450 6
190 582 536149589
453 3 4
116 891 3
585 875 495228925
191 718 6
4...

output:

-1

result:

ok single line: '-1'

Test #34:

score: 0
Accepted
time: 92ms
memory: 6176kb

input:

996 199992 199993 124753
205 430 710291462
748 756 293873327
59 894 536099901
632 890 9
452 316 3
652 215 10
273 487 8
469 308 301806104
620 183 4
401 401 946696222
305 647 1
925 765 518528395
980 190 3
289 597 815252846
509 691 262814273
279 155 3
708 808 4
878 326 296665089
993 513 3
883 903 1
317...

output:

4319483

result:

ok single line: '4319483'

Test #35:

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

input:

997 199993 199992 124253
469 654 830723036
65 266 47739481
202 516 43614641
450 876 737667977
641 801 147893631
866 193 8
994 801 774993226
195 398 2
383 177 6
146 782 9
379 379 192058079
320 539 4
303 86 934535571
939 262 8
704 536 762562635
700 419 1
455 92 627464094
408 731 1
671 514 160757934
40...

output:

2465177

result:

ok single line: '2465177'

Test #36:

score: 0
Accepted
time: 92ms
memory: 6044kb

input:

998 199994 199991 124351
415 390 904570266
833 971 232183018
379 44 4
48 884 626169357
276 73 610900123
796 900 508923131
470 553 829096662
577 319 8
869 52 2
120 684 9
38 486 722467116
131 55 967841018
294 256 73055903
958 350 580089254
86 86 228617822
318 469 842579267
368 387 3
271 958 906176840
...

output:

659354

result:

ok single line: '659354'

Test #37:

score: 0
Accepted
time: 2ms
memory: 3880kb

input:

991 1990 1994 478740
207 85 448218904
597 457 171948410
694 916 64279329
887 773 546537318
823 474 274118886
537 337 29463181
774 790 740341746
519 263 854029433
672 88 541727414
511 529 850564468
739 665 797508491
40 659 122614430
337 219 353063113
811 126 478325496
348 587 746769857
800 169 303996...

output:

1767887856

result:

ok single line: '1767887856'

Test #38:

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

input:

997 1991 1993 484173
852 732 126678270
135 936 229775881
570 641 437402237
371 549 696980033
822 184 101268287
437 537 354404827
134 78 711324352
688 325 693925447
686 684 913713164
517 539 56813322
894 901 208395516
29 775 257694171
335 484 764720970
940 183 85080357
175 633 769278190
568 320 79030...

output:

1833053865

result:

ok single line: '1833053865'

Test #39:

score: 0
Accepted
time: 2ms
memory: 3940kb

input:

993 1992 1992 480707
63 659 677224503
750 57 329741935
563 292 492017497
213 264 204565684
750 326 474751877
714 180 100924568
579 617 316599370
350 84 321786007
926 308 142010183
163 211 962351042
250 54 172653606
477 534 22944969
603 653 926301029
928 449 283289417
774 760 584645421
232 563 569605...

output:

1949479093

result:

ok single line: '1949479093'

Test #40:

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

input:

999 1993 1991 487053
845 849 847102702
858 888 48454285
952 568 163696556
614 873 871362801
324 419 496504727
715 418 594630937
840 185 73686216
114 841 40600395
999 995 263506041
97 309 290200784
287 7 109411009
79 236 351218008
356 196 983091766
156 427 467315914
295 62 225676544
457 968 40660581
...

output:

1949517923

result:

ok single line: '1949517923'

Test #41:

score: 0
Accepted
time: 75ms
memory: 6140kb

input:

10 200000 200000 6
9 8 986848285
8 3 931517081
1 10 990030276
6 8 22174654
3 9 741608620
7 10 996595127
3 4 405443883
2 9 448297485
10 7 280036332
4 2 638708919
1 8 846101420
1 9 383098176
2 2 4438084
4 7 915119923
5 6 471311946
9 5 750933612
8 7 15209562
4 2 486285449
5 10 344117831
7 4 497234139
6...

output:

23502

result:

ok single line: '23502'

Test #42:

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

input:

10 200000 200000 23
3 7 658934308
9 10 81386292
5 4 285652873
2 5 772523383
1 1 795730594
5 8 50741312
9 2 971246865
2 7 567991455
4 8 689065221
6 6 344345044
9 10 70929696
6 8 650959161
10 6 295074773
3 1 808325119
5 4 22435862
2 2 731323941
6 9 146620290
4 2 917959872
1 9 886553133
9 4 727689938
4...

output:

26277

result:

ok single line: '26277'

Test #43:

score: 0
Accepted
time: 88ms
memory: 6056kb

input:

300 200000 200000 139
236 121 474662147
167 124 651551538
217 250 689739994
250 69 700658272
186 222 499487702
7 212 257241553
64 42 975321190
83 92 880594246
205 261 169920659
278 107 531192669
170 58 699055139
170 204 693987112
50 296 877792979
222 182 151537649
269 6 253701023
209 98 597012262
9 ...

output:

294541

result:

ok single line: '294541'

Test #44:

score: 0
Accepted
time: 87ms
memory: 5940kb

input:

300 200000 200000 20412
210 264 216203670
214 250 974296634
279 32 929952113
38 18 249913810
108 167 260470215
86 66 910068208
249 5 827240466
9 116 953392349
225 40 102480156
239 94 279596519
30 279 818189190
80 184 477648217
60 5 610659451
192 152 679644035
147 35 926830323
249 59 548262871
244 13...

output:

1102575

result:

ok single line: '1102575'

Test #45:

score: 0
Accepted
time: 87ms
memory: 6328kb

input:

1999 199999 199999 1002
604 1732 501973414
1124 1158 896848515
943 536 728730188
381 40 495131150
1204 1018 574946791
246 1677 57734808
1501 969 120747416
1432 994 962365222
1057 256 504254448
1902 886 686620566
1620 1954 520319198
1163 1599 6285366
1986 927 383847231
1893 272 421070825
1576 1519 57...

output:

2306516

result:

ok single line: '2306516'

Test #46:

score: 0
Accepted
time: 88ms
memory: 6284kb

input:

1999 199999 199999 934932
710 356 986359567
163 502 931269266
45 1640 894661892
248 1884 439841951
964 985 923332517
578 527 651980920
1954 1659 377309921
1658 485 565876604
1800 1410 431357741
1752 1368 666306267
136 765 157434202
244 1692 967595289
628 164 183326670
1101 1403 888498455
1065 1177 8...

output:

8279303

result:

ok single line: '8279303'

Test #47:

score: 0
Accepted
time: 87ms
memory: 6412kb

input:

1999 199999 199999 1997001
658 1076 283443107
638 281 264713525
1384 492 753401774
9 519 536302760
648 1497 978398389
119 1531 438321711
853 320 112394960
1717 1811 871346582
1862 781 39868053
1098 1506 489357373
1349 1606 524593749
418 422 382334468
403 905 91375635
966 246 105604949
1184 1932 5685...

output:

34065884

result:

ok single line: '34065884'

Test #48:

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

input:

1999 199999 199999 903
1947 1930 7
1852 1509 38
1542 1490 12
1397 1155 20
1145 9 15
1771 626 5
1853 735 28
1457 149 24
103 1036 95
970 598 26
857 618 3
1367 1495 3
215 526 88
419 1906 54
1348 1504 38
178 775 27
388 1216 52
1648 874 83
1063 1611 67
286 995 33
680 1662 37
449 1211 37
1334 1894 64
724 ...

output:

1

result:

ok single line: '1'

Test #49:

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

input:

1999 199999 199999 54468
738 1355 12
266 279 26
1029 1930 77
438 693 70
260 1050 34
1800 1035 27
1099 589 60
1934 1559 62
237 1214 29
1443 1136 33
571 808 24
1374 1209 6
398 1431 66
910 157 39
454 414 60
196 648 94
1520 647 23
1634 1824 22
1362 100 23
1612 1213 11
1896 1831 51
907 1056 90
1012 790 9...

output:

1

result:

ok single line: '1'

Test #50:

score: 0
Accepted
time: 2ms
memory: 4124kb

input:

2000 1000 1000 6879
1682 164 667209728
807 1245 46633516
1746 783 466227603
1066 1001 348097974
1044 271 759817769
97 936 51212234
75 1831 17340243
824 662 67837847
1498 120 160058344
1027 1184 941941144
1775 1269 22603192
1185 198 411282331
1065 65 105993975
77 626 353162560
1373 297 157133433
367 ...

output:

856920573

result:

ok single line: '856920573'

Test #51:

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

input:

2000 200000 87 5103
174 220 879476599
558 1943 13889882
530 839 757645356
614 1677 343073496
300 1480 734125448
592 555 336534868
785 1638 558198904
637 534 430996677
427 1519 215449815
1085 622 92229729
1452 880 993560457
1079 662 487134334
715 1566 285881213
366 737 554460906
14 556 609656702
430 ...

output:

4499824

result:

ok single line: '4499824'

Test #52:

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

input:

2000 103 199999 7540
452 1208 96
408 462 32
1461 428 100
997 678 21
1789 668 11
853 1617 38
1095 738 1
487 932 39
425 548 71
1573 1566 96
517 403 58
1050 1161 12
1815 1135 67
420 990 1
473 531 62
1120 1063 5
1049 1281 75
1146 598 45
1373 536 62
844 533 26
1514 1368 68
318 1447 65
202 1123 83
54 1227...

output:

4782088

result:

ok single line: '4782088'

Subtask #2:

score: 5
Accepted

Test #53:

score: 5
Accepted
time: 185ms
memory: 51592kb

input:

200000 100000 100000 7628995
23677 113459 839167193
165893 15365 669621527
26287 109671 214795757
156871 136723 522277985
9957 100463 806718116
104783 161385 156110975
184577 92225 545172629
57373 130083 980035338
167231 49597 919886451
115601 24325 717233004
99413 141311 737488449
83437 62759 76873...

output:

502149991

result:

ok single line: '502149991'

Test #54:

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

input:

200000 200000 87 2694
197233 86229 181875035
85167 196363 328068482
177795 65479 693403443
119609 181977 588691030
115815 139981 486110961
92473 20483 199129328
166989 95385 210368646
98095 54673 357307451
122543 94377 907487846
46611 80735 71787832
158893 117071 521262491
92051 104395 365725125
142...

output:

11965880

result:

ok single line: '11965880'

Test #55:

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

input:

200000 103 199999 1593
75203 150269 64
68675 175215 100
176335 11837 94
33623 63279 56
16617 86741 63
167219 52783 58
6575 134399 1
144065 114171 2
32625 99459 50
35311 152509 36
132975 12211 8
175275 107903 23
17477 21319 95
157759 66683 71
34577 78339 26
154003 26703 18
187863 90945 74
116071 1089...

output:

7037526

result:

ok single line: '7037526'

Test #56:

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

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #57:

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

input:

1 1 0 0
1 1 1

output:

0

result:

ok single line: '0'

Test #58:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #59:

score: 0
Accepted
time: 85ms
memory: 5948kb

input:

2 200000 200000 1
1 1 540311820
1 1 825820034
1 1 555157427
1 1 288420080
1 1 672135630
1 1 726777321
1 1 526670467
1 1 959728057
1 1 146842949
1 1 122695951
1 1 432194433
1 1 381185144
1 1 686598677
1 1 215624542
1 1 458312135
1 1 986262083
1 1 947920916
1 1 934427659
1 1 782364899
1 1 715992893
1 ...

output:

-1

result:

ok single line: '-1'

Test #60:

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

input:

2 200000 200000 1
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 1000000000
1 1 10000000...

output:

-1

result:

ok single line: '-1'

Test #61:

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

input:

200000 0 200000 352487
135712 118584 670867088
72546 31680 1279343
123412 184392 678367510
125022 192330 57001931
134050 61434 212353526
6066 95972 717546833
47726 9232 949490922
166856 33998 986508808
166254 92344 143252836
82392 100980 919436840
84316 12292 753153826
192154 134452 832321404
144418...

output:

216679869

result:

ok single line: '216679869'

Test #62:

score: 0
Accepted
time: 168ms
memory: 41604kb

input:

200000 200000 0 1089706
197033 84309 947754387
112807 60173 477333202
102607 132751 957665006
143619 102001 642146230
32419 155751 770317403
53835 4703 414754921
9463 17929 312775978
172373 41459 29632969
48451 142975 596586913
36019 180115 791609008
145487 162325 699635731
177243 94157 221311090
18...

output:

245598855

result:

ok single line: '245598855'

Test #63:

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

input:

200000 200000 200000 19999900000
86215 110793 27420223
115281 150421 94498
135039 177319 663933319
36159 42207 779673045
183713 40779 749203477
19775 65311 4733
107303 126899 734749608
156297 176907 75566437
125743 186407 98466
140359 177109 654885923
71583 37783 772116721
159971 195153 554369442
98...

output:

-1

result:

ok single line: '-1'

Test #64:

score: 0
Accepted
time: 188ms
memory: 46116kb

input:

200000 200000 200000 19999900000
85515 12697 64028
96111 81277 723665166
2725 17313 680441413
93491 175625 540828929
67585 1395 36003
67231 61263 36674
38071 156361 828146734
28859 160423 12411
145939 126471 712935428
94263 91967 539663194
63247 197497 523841579
78633 56647 13319
167061 116147 69378...

output:

-1

result:

ok single line: '-1'

Test #65:

score: 0
Accepted
time: 193ms
memory: 46380kb

input:

200000 200000 200000 19999900000
148005 59733 752041265
123653 133439 52211
145097 100735 849514916
81383 172715 82449
73561 151351 5461
89063 14693 344507089
21037 114603 83348
58421 27517 990178176
92093 52843 44132
47187 108097 654752253
125675 121519 379610893
180175 114853 432259513
101563 1539...

output:

-1

result:

ok single line: '-1'

Test #66:

score: 0
Accepted
time: 180ms
memory: 46060kb

input:

200000 200000 200000 19999900000
84373 49303 809503019
121957 178579 27747
17401 130691 81723
167037 65841 156510963
150147 91835 955602352
38921 199303 799434899
148503 143389 545115194
167915 178111 32040
157739 135137 406444987
151557 114653 959815310
183647 73983 60436
22453 173189 907941124
942...

output:

-1

result:

ok single line: '-1'

Test #67:

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

input:

200000 0 0 0

output:

0

result:

ok single line: '0'

Test #68:

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

input:

200000 0 0 1

output:

-1

result:

ok single line: '-1'

Test #69:

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

input:

200000 0 0 19999900000

output:

-1

result:

ok single line: '-1'

Test #70:

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

input:

200000 200000 200000 0
87819 103509 211262
70831 128635 830521513
113429 141129 784161896
129435 11587 889301002
44001 115103 595627949
47949 142581 707781370
131047 3629 922790958
23679 66389 332015888
129675 123163 971290575
179611 66043 669206978
97337 71783 492187074
7571 2423 622850189
38605 78...

output:

0

result:

ok single line: '0'

Test #71:

score: 0
Accepted
time: 226ms
memory: 51172kb

input:

200000 200000 200000 1
156245 167853 177174928
188863 72787 774437619
4585 19395 257360617
128879 170657 682214518
161355 176611 304747786
43047 106383 127598967
24279 82135 957118009
196215 59199 751930028
170851 67831 778264730
137919 197693 331012429
11523 16765 713111895
97017 106453 758909521
1...

output:

2038

result:

ok single line: '2038'

Test #72:

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

input:

200000 200000 200000 7
57525 173001 851535810
90143 40469 390254518
47345 90621 810622886
30795 49971 298834588
189903 46443 134186592
137675 28429 339466374
69059 184047 584089294
147913 80315 8146656
179297 104151 362297351
70649 53131 388526766
107483 143767 505780466
148763 182199 408802373
1033...

output:

15612

result:

ok single line: '15612'

Test #73:

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

input:

200000 200000 200000 46
111931 134159 889741544
149639 128081 372249571
23933 64913 441243094
110657 34439 947713738
181857 11825 495039256
180791 95409 524765235
163423 157431 391773005
97399 19671 904565768
187819 122831 911398340
57913 31101 694661062
101755 67855 888773520
130677 22999 216816765...

output:

171465

result:

ok single line: '171465'

Test #74:

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

input:

200000 200000 200000 644
117565 176843 664885033
56817 162365 734743320
54117 113661 518155584
42661 109889 910590800
184271 71485 832406650
134697 122943 821929672
165513 26247 148140143
8219 181481 86904456
123701 150771 215687547
162763 49093 804995017
68581 130605 871496281
129291 12421 81737374...

output:

3160928

result:

ok single line: '3160928'

Test #75:

score: 0
Accepted
time: 230ms
memory: 51132kb

input:

200000 200000 200000 9470
171111 2867 135877098
129249 152799 427879861
44787 147563 166499191
4049 96289 733086628
121413 161723 119790707
53823 26279 736094176
53209 21459 928020229
51875 164485 617069767
34989 162955 337423730
108607 67767 141743345
117349 49929 922096240
134763 159225 820844700
...

output:

39338620

result:

ok single line: '39338620'

Test #76:

score: 0
Accepted
time: 227ms
memory: 52932kb

input:

200000 200000 200000 207102
29097 162609 472583329
136721 82267 502393608
178201 7889 162637370
43571 135237 698283102
168337 172757 347459265
126915 60005 552335616
103453 54641 14743234
59795 129775 702064533
171131 21901 921708772
124561 16561 807682192
33863 11007 13951811
172639 105263 96633136...

output:

202638987

result:

ok single line: '202638987'

Test #77:

score: 0
Accepted
time: 255ms
memory: 54864kb

input:

200000 200000 200000 66872916
27507 50665 155273602
63343 156069 75020472
181663 50753 520878795
77509 28129 705673982
33245 174951 976831676
153713 85163 721085033
127259 6161 716492030
148789 134331 750274596
8561 57175 17590758
63299 66635 763607824
81369 4431 34802407
169897 47365 6726815
184919...

output:

267941690

result:

ok single line: '267941690'

Test #78:

score: 0
Accepted
time: 255ms
memory: 58200kb

input:

200000 200000 200000 1615967186
28597 192271 748036920
8605 23351 686852552
23287 29959 390000705
172725 134059 250213783
20357 83315 37310191
148995 71921 674659550
147185 167215 907355289
77011 197963 567378302
147807 91251 465576335
190569 66209 499989959
18711 151301 478858869
96941 134849 73221...

output:

369129717

result:

ok single line: '369129717'

Test #79:

score: 0
Accepted
time: 277ms
memory: 60736kb

input:

200000 200000 200000 19999900000
112503 57253 66896775
142933 121865 459414667
99371 122355 841207482
18691 173709 976104678
29297 122363 79369742
39535 103593 852787869
92907 33993 541571419
194967 10385 694194246
103103 134627 189235736
150783 145017 527545307
187573 119507 626973719
181775 111443...

output:

-1

result:

ok single line: '-1'

Test #80:

score: 0
Accepted
time: 230ms
memory: 51324kb

input:

200000 200000 200000 0
82843 119905 2583524
10507 18913 991293003
171809 64495 881500988
23257 66045 14535911
95047 90719 840253158
130695 69835 336717057
80583 11407 15024676
131497 26551 424800825
127311 6023 84888655
66333 68761 650490282
27757 100653 788929702
164597 174717 3551432
108259 91059 ...

output:

0

result:

ok single line: '0'

Test #81:

score: 0
Accepted
time: 224ms
memory: 51964kb

input:

200000 200000 200000 1
100811 121599 138028622
83761 143579 613818666
188697 90929 978369338
172647 61673 721538906
98327 128307 855590378
18281 152243 624679278
4781 196535 633678011
153681 8687 362612591
61427 68167 597252991
152747 46175 996937075
146283 146607 947213497
87217 193847 572910775
88...

output:

6

result:

ok single line: '6'

Test #82:

score: 0
Accepted
time: 239ms
memory: 51224kb

input:

200000 200000 200000 4
70805 100727 915972585
9871 423 20063341
95861 1189 166742797
44987 48891 364010233
110397 92427 89481016
112049 41599 351108130
124495 182231 304774083
459 98879 654767300
81797 131237 492054186
144729 75043 416998693
39807 50047 296330701
9309 153391 574952294
115185 28801 5...

output:

30

result:

ok single line: '30'

Test #83:

score: 0
Accepted
time: 241ms
memory: 50796kb

input:

200000 200000 200000 86
153383 11103 403918135
99409 144239 164593728
182949 10301 753173665
151897 192119 702947277
187711 131925 881466743
154587 24647 295938676
30497 84419 649572217
176585 66335 997147073
5753 1873 228093143
87479 65437 754608340
179955 78555 900370553
75275 142099 754833229
701...

output:

70

result:

ok single line: '70'

Test #84:

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

input:

200000 200000 200000 126
58325 112789 991133947
26987 137775 672190970
80473 167605 172720704
79117 182819 156150287
131239 82801 918367499
120195 105443 593878101
194587 11451 109101989
73607 40151 20162560
32309 151297 110017594
69237 36435 593075481
57789 64297 154442585
134043 100663 656524375
3...

output:

11

result:

ok single line: '11'

Test #85:

score: 0
Accepted
time: 227ms
memory: 51716kb

input:

200000 200000 200000 4168
142043 107975 814664551
124739 85295 511693466
76677 81869 567575769
46869 35815 340726821
79235 2583 766743732
76081 81839 640096127
191953 42843 747019292
137509 7219 90
12773 113211 755306384
42985 67677 564510301
34323 104351 401667666
172125 173955 67979333
93503 6989 ...

output:

39

result:

ok single line: '39'

Test #86:

score: 0
Accepted
time: 245ms
memory: 53476kb

input:

200000 200000 200000 736121
198763 72285 163834706
128665 178573 19
86459 147699 923501303
74591 2757 790745419
155137 23345 9
141451 67849 54
168899 31301 52
181411 71269 600237233
32203 143045 213145787
168661 160363 83121315
165259 31537 80
47199 43249 92
112143 33477 980402833
47707 62035 593882...

output:

48

result:

ok single line: '48'

Test #87:

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

input:

200000 200000 200000 47010116
197353 153635 432621012
182969 15291 19
26115 68265 5
161387 84017 440653544
22667 18401 921402945
23603 110533 52804844
71083 34611 28
63401 47113 652057634
18363 62213 719650067
80071 123547 715385190
57023 35361 44
84037 64051 542266879
155871 131941 9
46449 195331 7...

output:

53

result:

ok single line: '53'

Test #88:

score: 0
Accepted
time: 256ms
memory: 57444kb

input:

200000 200000 200000 1348160454
65481 175369 60
116069 29613 36480437
25465 197007 5
166653 121999 4
93545 130519 241445605
65073 159281 73
92419 157433 61
137743 144567 528229725
20099 62855 57
104317 198329 27
186745 25903 954572672
90133 135343 693873674
41013 121387 13273762
46705 14257 59
10911...

output:

71

result:

ok single line: '71'

Test #89:

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

input:

200000 200000 200000 19999900000
103853 52629 160834957
116877 159979 51
181147 16769 41821995
151625 128229 65
195005 154095 1
167795 44515 71
197149 161495 530415114
111515 33907 950395437
167317 65991 8
68889 134661 79
78277 51137 12
199689 158023 56
92327 59039 388003009
157535 194629 788091982
...

output:

-1

result:

ok single line: '-1'

Test #90:

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

input:

99995 199991 199994 624425183
98859 78485 3
29499 92661 2
58487 95743 357500000
4813 16791 10
79743 59561 448767140
7423 69929 7
91095 51699 39233009
95311 72737 7
51975 51975 195560988
57955 22455 528064101
39661 42333 5
29453 11119 4
19647 69017 6
15045 46757 3
4017 66461 986429815
68073 48361 101...

output:

408744771

result:

ok single line: '408744771'

Test #91:

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

input:

99993 199992 199993 624410150
81229 64621 770206314
75751 74927 2
89433 645 736361003
95153 6099 710821792
41375 86187 96941540
38945 75663 547715721
19489 36311 88954176
65209 58289 5
41837 42775 782171403
53377 40181 37311742
5917 71903 7
84629 50895 954520344
93321 86611 88152955
76365 76365 7621...

output:

69748190

result:

ok single line: '69748190'

Test #92:

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

input:

99997 199993 199992 624401156
4757 48453 9
67283 21061 185605478
61665 2097 10
38771 38771 452914182
18651 2663 3
18329 18329 549230371
61835 54501 86613396
33885 96127 8
19789 57679 474571521
88129 79477 286313725
69257 91557 10
5067 96465 6
81633 47587 4
21679 45997 391891940
8489 47771 41707479
8...

output:

10055771

result:

ok single line: '10055771'

Test #93:

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

input:

99998 199994 199991 624550181
58551 18371 2
89757 2569 5
83295 60611 830711659
82083 86353 6
63511 32679 495278250
75525 74309 581507821
17561 13831 9
99025 79867 10
89727 35533 5
57967 69093 487847225
16197 91821 7
71837 16335 2
54495 91709 279381595
96515 65843 584314693
31229 59565 854536334
5741...

output:

929135

result:

ok single line: '929135'

Test #94:

score: 0
Accepted
time: 76ms
memory: 5892kb

input:

10 200000 200000 1
1 1 871886556
3 3 310062577
9 3 460488634
7 9 624913993
1 1 453682703
5 1 528633630
7 9 888263202
9 5 207212424
5 1 676247129
9 3 459479991
1 5 701109018
3 5 528022079
7 7 239662509
5 9 593102049
5 7 886839714
5 3 936381589
3 7 697071901
7 7 833204472
7 7 335128519
7 9 168519473
1...

output:

645

result:

ok single line: '645'

Test #95:

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

input:

10 200000 200000 45
7 3 172564753
9 9 33158789
3 7 141697842
5 9 821787431
3 9 784337536
9 1 637206863
5 7 418649261
3 1 15655083
3 9 535579995
5 5 239035786
7 5 515129415
3 1 116547607
9 9 254697597
7 5 227298431
9 9 237990112
9 9 562418632
7 9 476117158
3 9 658789408
9 1 677858614
3 1 690544905
5 ...

output:

-1

result:

ok single line: '-1'

Test #96:

score: 0
Accepted
time: 83ms
memory: 5944kb

input:

300 200000 200000 58
61 215 119098913
23 263 645656739
9 27 131605941
211 281 299607736
219 211 741794331
67 217 868045878
13 197 758598024
261 255 868199079
277 203 284970974
77 115 882652816
97 221 704828032
67 145 97237751
241 229 21146083
217 7 682103610
153 65 556790529
297 197 869135277
209 19...

output:

127339

result:

ok single line: '127339'

Test #97:

score: 0
Accepted
time: 83ms
memory: 5924kb

input:

300 200000 200000 8603
67 187 232816687
257 37 53701857
81 165 283912451
273 7 507923216
21 19 149845962
95 233 623165066
31 157 43303664
249 3 477341087
135 87 433355790
297 19 145552835
93 223 156244303
199 65 46338097
35 137 428773950
159 85 275342633
69 147 326833157
191 53 18868495
77 285 22625...

output:

963592

result:

ok single line: '963592'

Test #98:

score: 0
Accepted
time: 240ms
memory: 51400kb

input:

199999 199999 199999 22589
37075 144273 56995571
148973 112739 464743159
23807 26417 195516980
47065 13751 394432559
19693 713 510556844
98041 125805 622794862
162089 44365 531166968
114623 128079 544375809
176911 18673 927620957
88865 117193 938470719
75365 114241 80684631
4033 143217 371707337
186...

output:

77980650

result:

ok single line: '77980650'

Test #99:

score: 0
Accepted
time: 249ms
memory: 55720kb

input:

199999 199999 199999 25515937
127295 113885 322807916
179203 6251 909116728
2043 143279 38393641
33027 42715 65077951
117623 198985 944085981
186297 143451 503424450
118989 148601 812211230
113377 71291 505099088
54107 157159 90071716
20441 59911 1403830
157023 110009 608627420
60987 17221 339305281...

output:

259424947

result:

ok single line: '259424947'

Test #100:

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

input:

199999 199999 199999 19999700001
54549 62573 903472942
127703 177949 408945470
35365 88921 625226989
146599 23117 901759959
15797 145417 904924493
45687 43793 373169943
22041 104977 780538819
165249 60049 681622319
26371 169857 183728575
184025 22889 809424459
69439 41279 121348033
100897 61823 1745...

output:

-1

result:

ok single line: '-1'

Test #101:

score: 0
Accepted
time: 239ms
memory: 53404kb

input:

199999 199999 199999 187468
30955 199915 8
100047 92811 89
87267 70205 88
185401 92353 32
129415 153239 10
60239 113113 8
108613 146239 36
47721 113431 95
100457 65729 26
77745 33621 67
145739 60201 77
118109 114731 2
41159 55637 45
143483 155545 59
69549 79797 62
103925 177517 72
25699 152457 19
34...

output:

20

result:

ok single line: '20'

Test #102:

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

input:

199999 199999 199999 5321422162
99023 149963 72
157091 7497 86
15951 198347 94
50001 71951 68
27791 136549 93
180369 176341 90
111471 42615 56
88355 40291 93
66039 102573 10
16031 61219 70
150811 66987 62
83357 129139 19
79959 81249 89
149559 173693 48
141015 140903 38
23491 167949 48
169681 73811 1...

output:

90

result:

ok single line: '90'

Subtask #3:

score: 6
Accepted

Test #103:

score: 6
Accepted
time: 0ms
memory: 3528kb

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #104:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #105:

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

input:

2 10 200000 1
2 1 319832429
1 1 412617159
2 1 337734185
1 2 674652880
1 2 454610992
2 2 688717944
1 1 189208056
2 2 951221780
1 2 594191431
2 2 87592160
1 2 833491749
2 2 732961971
2 1 575969648
2 2 268359887
2 1 436382098
1 2 514959278
1 2 305446083
1 2 365989813
1 2 296840111
1 1 541558213
1 1 497...

output:

10104

result:

ok single line: '10104'

Test #106:

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

input:

2 10 200000 1
1 1 1000000000
1 1 1000000000
1 2 1000000000
1 2 1000000000
1 2 1000000000
1 1 1000000000
2 1 1000000000
2 2 1000000000
2 2 1000000000
2 2 1000000000
1 1 1000000000
1 2 1000000000
1 1 1000000000
2 1 1000000000
1 1 1000000000
1 1 1000000000
2 1 1000000000
1 1 1000000000
2 2 1000000000
2...

output:

1000000000

result:

ok single line: '1000000000'

Test #107:

score: 0
Accepted
time: 105ms
memory: 45836kb

input:

200000 10 200000 17900
199675 76237 290240030
50211 6922 761990536
92097 120746 607490
192856 130409 616541101
50427 80049 330957286
129588 180294 466199684
8674 110653 155297749
91380 156344 798960399
102127 40858 801752583
94673 105892 152356242
185676 6183 263664373
169026 112948 812501808
93517 ...

output:

75425485

result:

ok single line: '75425485'

Test #108:

score: 0
Accepted
time: 173ms
memory: 57516kb

input:

200000 10 200000 11791021341
90115 14234 985783971
123477 154651 628493605
123171 47179 220847663
8072 163826 30383173
174753 12792 15862638
172837 96919 880800330
92696 166466 443031361
85298 185851 999558577
23737 111350 809362300
24551 127050 920973896
121483 145215 67814677
78536 41919 475800490...

output:

949367959

result:

ok single line: '949367959'

Test #109:

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

input:

200000 0 200000 423432
117280 87297 405090778
161764 93979 279208002
169095 190396 237565477
5136 81072 251360373
177384 130645 595157997
5282 38206 898866303
150431 96891 829055730
18413 42187 599085995
75585 47004 557307885
92187 77157 349172549
63029 186638 993483250
37685 198246 538754012
119056...

output:

404806867

result:

ok single line: '404806867'

Test #110:

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

input:

200000 10 0 1583868
66186 49114 583417488
79347 122356 957296935
4161 178945 973881307
39875 85386 62804962
62164 81798 964069340
6410 188411 31431750
67426 6153 513781110
49101 116783 513947988
61043 89483 259723608
14116 90504 23294861

output:

-1

result:

ok single line: '-1'

Test #111:

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

input:

200000 10 200000 19999900000
47625 147346 8
147346 121067 9
97009 179826 2
155552 97009 1
179826 22149 3
15370 4310 5
135552 47625 7
121067 131030 10
4310 135552 6
22149 15370 4
92707 136627 90227
20274 369 174990
32793 164281 194588
56508 95231 92612
117675 125225 114617
42843 81551 39780
149173 15...

output:

199999

result:

ok single line: '199999'

Test #112:

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

input:

200000 10 200000 19999900000
45665 143462 7
22696 184210 2
38538 57388 9
184210 154285 3
125307 22696 1
149825 71332 5
143462 38538 8
154285 149825 4
57388 182077 10
71332 45665 6
163095 156887 174710
77920 77020 63954
85503 109613 119638
46319 118285 60934
66569 45264 83574
73519 101885 163357
1583...

output:

200000

result:

ok single line: '200000'

Test #113:

score: 0
Accepted
time: 116ms
memory: 46344kb

input:

200000 10 200000 19999900000
739 28876 199992
53663 1295 199998
43161 52504 200000
158247 739 199993
2816 184328 199996
52504 53663 199999
1295 2816 199997
52726 158247 199994
28876 8395 199991
184328 52726 199995
130045 124454 95456
117404 39359 188185
42676 84681 4828
105147 95150 194669
17107 579...

output:

199999

result:

ok single line: '199999'

Test #114:

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

input:

200000 10 200000 19999900000
19794 183474 199991
71973 145759 199999
167290 188987 199995
6730 167290 199996
92616 6730 199997
93098 157369 199993
145759 92616 199998
104691 71973 200000
157369 19794 199992
188987 93098 199994
4529 33398 169717
116172 158258 118532
69720 25407 140713
173220 192301 1...

output:

200000

result:

ok single line: '200000'

Test #115:

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

input:

200000 0 0 0

output:

0

result:

ok single line: '0'

Test #116:

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

input:

200000 0 0 1

output:

-1

result:

ok single line: '-1'

Test #117:

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

input:

200000 0 0 19999900000

output:

-1

result:

ok single line: '-1'

Test #118:

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

input:

200000 10 200000 0
146668 190255 646706475
71516 174249 65976309
173393 55930 434227341
38682 164404 792088710
68045 174249 105770742
190255 24008 378601596
68045 174249 584120597
68045 68045 891140070
71516 71516 121444300
24008 173393 638520585
42552 123134 440551564
172416 148702 205154389
80345 ...

output:

0

result:

ok single line: '0'

Test #119:

score: 0
Accepted
time: 103ms
memory: 45048kb

input:

200000 10 200000 1
18089 125148 634373061
26320 138377 746998187
125148 130407 287480602
136290 4926 478063834
136333 147458 29423436
26320 147458 334115471
4926 136290 505364255
18089 26320 866606210
11249 77957 605205962
136333 11249 440411926
170380 191070 819377443
150060 41355 635345633
143709 ...

output:

2407

result:

ok single line: '2407'

Test #120:

score: 0
Accepted
time: 99ms
memory: 46132kb

input:

200000 10 200000 4
131932 102405 14740950
95390 60349 599957231
62719 96049 468132040
96049 196778 435897371
147221 147221 710991146
69099 139866 753644389
130732 22961 374767514
118319 62719 793210617
14592 172623 872022637
131932 147221 588107750
133618 115753 634870732
69458 144612 651075961
8687...

output:

14977

result:

ok single line: '14977'

Test #121:

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

input:

200000 10 200000 92
26204 41682 132397613
11386 43267 432400482
26204 145442 188527020
124727 65248 170978952
26613 172005 567702196
146166 39798 679712885
146166 39798 953781917
124727 41682 826584416
146166 146166 117167249
65248 11386 787325743
764 17622 571020090
171608 112618 89050875
21593 172...

output:

473019

result:

ok single line: '473019'

Test #122:

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

input:

200000 10 200000 672
151843 72188 754208507
186567 155545 192251945
72188 173580 807040666
173580 155545 413157526
143249 143249 343025568
143249 182692 983484260
182692 21150 153868493
173580 155545 648383151
151843 182692 108954433
156381 14221 612434692
8027 76055 276048757
29885 107311 354554984...

output:

3501158

result:

ok single line: '3501158'

Test #123:

score: 0
Accepted
time: 103ms
memory: 46824kb

input:

200000 10 200000 5413
95488 104057 66278284
58623 58623 818395626
99093 124205 414738887
99093 158331 881420357
159736 67384 193983425
67384 58623 623301482
159736 141485 530044249
158331 146846 170069165
95488 158331 521843529
144566 99093 996200413
47960 153496 68751236
48094 54076 759978913
2873 ...

output:

25561771

result:

ok single line: '25561771'

Test #124:

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

input:

200000 10 200000 607219
117398 78777 25237306
122250 107989 217199414
100967 69009 323823567
78777 78777 653032486
43957 47258 709036359
107989 30352 736599336
152731 47258 974489271
69009 122250 631296609
69009 43957 982998301
164327 117398 451874824
78667 87007 949453372
176540 180070 825887209
29...

output:

424224418

result:

ok single line: '424224418'

Test #125:

score: 0
Accepted
time: 134ms
memory: 47808kb

input:

200000 10 200000 38942692
191843 87774 48763750
42448 181646 153085306
78078 10204 342154140
42448 45480 342538264
51194 78078 40436760
95235 39182 532944349
79153 79153 495283828
108632 141932 193232728
78078 121421 507359193
141932 108632 799596562
141888 166667 289423598
62108 182515 150884302
43...

output:

506971462

result:

ok single line: '506971462'

Test #126:

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

input:

200000 10 200000 3867596036
101129 178836 611548548
71053 23325 51723100
23325 197101 732184179
113289 40120 919460669
71053 12789 146285015
37966 23325 463373360
40120 12789 690404961
34895 40120 689138722
178836 12789 350156365
40120 23325 969795259
64088 12703 150877304
125299 69683 377982548
190...

output:

659435029

result:

ok single line: '659435029'

Test #127:

score: 0
Accepted
time: 178ms
memory: 57708kb

input:

200000 10 200000 19999900000
19948 93224 696463523
187941 81537 209135633
70892 81537 80053781
24348 139884 806003775
187941 73976 934692473
167817 167817 45539332
93456 24348 405608615
173940 167817 358543555
70892 73976 806171243
24348 173940 495263721
143061 46638 446762613
89043 9162 584904381
4...

output:

-1

result:

ok single line: '-1'

Test #128:

score: 0
Accepted
time: 104ms
memory: 45488kb

input:

200000 10 200000 0
51897 141304 64
125281 55107 6
160539 169899 18
55107 125281 75
134103 100791 22
134103 92211 69
169899 55107 78
125281 55107 78
110799 51897 127287266
169899 134103 85
137999 70531 886030502
126853 67828 763444764
6746 128867 630841156
131235 16144 483070630
75851 127161 25109450...

output:

0

result:

ok single line: '0'

Test #129:

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

input:

200000 10 200000 1
132839 73305 8
66415 66415 90
57701 174971 79
66415 174971 18
183186 132839 19
89931 89931 61
179694 73305 40
73305 174971 6
17869 89931 81
73305 132839 840562812
125249 112893 879029614
194877 19061 138829945
81475 120055 169500004
11311 70715 654559512
188750 172969 324123184
17...

output:

6

result:

ok single line: '6'

Test #130:

score: 0
Accepted
time: 110ms
memory: 44700kb

input:

200000 10 200000 4
56795 118439 74
7633 121769 207221193
94262 56795 99
122334 68618 65
121769 61460 35
133080 7633 56
56795 56795 74
122334 1833 1
121769 7633 90
94262 121769 15
196938 5748 486304794
154729 73605 706011974
117668 80031 609841298
38907 66933 976840777
25959 153246 121939463
65979 17...

output:

17

result:

ok single line: '17'

Test #131:

score: 0
Accepted
time: 105ms
memory: 45836kb

input:

200000 10 200000 69
34305 198290 43
134403 50880 28
12535 118969 9
149 189809 89
109244 162754 28
198290 118969 97
149 197773 24
198290 132425 73
189809 118969 801144804
162754 150623 98
95003 171197 415768639
173347 125597 919360137
113494 180067 594834693
115761 147604 588304425
142713 6816 887247...

output:

194836

result:

ok single line: '194836'

Test #132:

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

input:

200000 10 200000 199
177417 199866 318682817
99595 110745 97
127845 79799 47
81292 60018 18
199866 145887 94
184952 81292 22
127845 175345 47
110745 199866 53
184952 81292 67
48266 79799 28
85823 190048 384818214
194336 59792 244657121
39439 53627 108564530
89057 168528 347568658
156739 185153 88857...

output:

651529

result:

ok single line: '651529'

Test #133:

score: 0
Accepted
time: 97ms
memory: 46624kb

input:

200000 10 200000 2336
184617 52427 33
111293 52427 46
105785 111293 4
164129 27829 90
52427 52427 186174778
164129 34278 30
27829 27829 55
184617 52427 14
1326 164129 5
1326 176962 34
102771 139071 434244188
150738 199521 128736564
123841 108098 907689486
199383 58574 874299150
21239 153420 99504970...

output:

11153217

result:

ok single line: '11153217'

Test #134:

score: 0
Accepted
time: 121ms
memory: 45756kb

input:

200000 10 200000 519438
116130 101898 21
81936 54038 42
54038 64163 45
116658 171498 97
81936 101898 32
49315 179017 31
171498 64163 35
171498 81936 27
54038 132772 283198339
179017 49315 40
161198 165012 207070741
38350 46423 758311424
187878 183482 49180770
56851 130748 939913282
75920 162903 6556...

output:

422319245

result:

ok single line: '422319245'

Test #135:

score: 0
Accepted
time: 143ms
memory: 48312kb

input:

200000 10 200000 66643423
44513 44513 12
3503 77479 47
3503 24684 43
158230 121579 43
77479 158230 78
1119 44513 677352697
77479 24684 58
1119 69374 83
1119 77479 1
171086 42348 63
99622 122424 678349014
70595 36559 601320411
38950 94952 297745872
76915 181147 673313895
98967 29531 507080417
105881 ...

output:

516285768

result:

ok single line: '516285768'

Test #136:

score: 0
Accepted
time: 179ms
memory: 56480kb

input:

200000 10 200000 9835296767
77091 71557 61
77091 37679 44
77091 114986 100
181588 181234 946747104
120628 71557 75
71557 71557 74
120628 37679 17
2972 114986 37
181234 33702 12
71557 77091 96
120022 2014 373672414
199375 104181 330635751
105145 19370 967916951
93445 154353 560784836
69724 113303 854...

output:

860403485

result:

ok single line: '860403485'

Test #137:

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

input:

200000 10 200000 19999900000
198684 87285 36
10527 79494 35
36464 123562 54
60538 25496 49
38193 151136 72
60538 151136 36
22062 36464 34
22062 198684 17
22062 198684 53
36464 60538 564858326
23980 88045 888059354
75471 59269 951792068
126673 97202 674246525
176854 187902 347779968
189575 120710 136...

output:

-1

result:

ok single line: '-1'

Test #138:

score: 0
Accepted
time: 87ms
memory: 28344kb

input:

99991 10 199994 1200587363
7180 16144 89226268
24610 27853 784090381
5628 70613 111756823
42468 27836 372715094
29727 77918 223911677
35930 84754 884234966
39651 26307 210027899
87422 17822 965100919
97318 91132 991863731
30886 65782 144884689
76217 26846 447213471
20184 90114 782009979
7202 7202 62...

output:

1991460726

result:

ok single line: '1991460726'

Test #139:

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

input:

99997 10 199993 1199069062
76110 89727 992384512
23206 31555 610715512
29577 69916 785263595
41894 24032 103485118
74397 48107 462250182
36373 35577 325626106
60444 62133 996828881
2948 10534 278936261
60515 13347 288328099
44624 87005 256282562
44910 11716 66923121
10287 6928 10
76500 1822 1
88128 ...

output:

1996703346

result:

ok single line: '1996703346'

Test #140:

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

input:

99993 10 199992 1202254212
53981 1363 406301079
62188 46937 424399765
99402 62484 912983110
58640 93058 816626158
42729 33220 214785831
16039 49528 525960594
84424 45968 327603374
62753 65949 810964937
81834 3752 856237482
45236 88077 703262482
47286 53061 10
88564 45373 2
92111 33577 9
39564 87604 ...

output:

1912841674

result:

ok single line: '1912841674'

Test #141:

score: 0
Accepted
time: 116ms
memory: 29580kb

input:

99999 10 199991 1203333549
25284 66621 2126302
64346 38871 207331232
68432 36557 28459263
64526 52407 308956764
39502 54842 918103867
24691 33689 621737198
6278 51708 148666622
92982 39854 224082671
51430 33020 446493393
8609 68020 369472994
13443 41151 792063843
99729 53147 6
57851 66346 5
81071 69...

output:

1621434207

result:

ok single line: '1621434207'

Test #142:

score: 0
Accepted
time: 99ms
memory: 28608kb

input:

99995 10 199990 1203381974
93858 81578 812082680
44043 36941 196654074
41971 892 878002488
98645 2320 223299813
32071 92441 982957321
81448 16307 88222911
95168 85550 660103055
58738 68989 932257179
95748 40851 27536545
55386 79952 351808193
87731 43520 7
76608 33038 7
33350 40914 1
47880 86089 3
55...

output:

1932200532

result:

ok single line: '1932200532'

Test #143:

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

input:

99991 10 199994 1200930113
4842 67770 283061721
20851 74161 656597078
35915 32828 234390286
21084 87048 78464344
40688 567 210507677
26777 77790 873663699
31299 53619 718652950
84270 61656 885710495
30379 80442 359811261
49652 21904 469667241
20037 18935 2
92262 35026 528250358
94568 27870 230060998...

output:

1283015136

result:

ok single line: '1283015136'

Test #144:

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

input:

99997 10 199993 1202891556
18478 13442 560362647
80686 4459 191270057
98465 83044 370348787
62689 76504 981426034
47399 51107 442062386
76156 31176 494762561
57080 34219 148851218
63711 31431 44222492
63798 95008 940690107
50333 22276 672385714
39550 17141 4
34589 31733 8
18093 64701 7
65448 19755 1...

output:

1441247546

result:

ok single line: '1441247546'

Test #145:

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

input:

99993 10 199992 1198481428
58117 94840 740736212
85414 49787 662985037
42692 15237 879272699
91602 49689 165513247
96443 40045 72624742
62673 73227 152088607
8029 3143 537188318
41880 96050 521150877
15854 72248 150971171
36007 81140 265693408
74491 78045 8
23615 57969 9
73026 86679 801772339
64683 ...

output:

999847696

result:

ok single line: '999847696'

Test #146:

score: 0
Accepted
time: 89ms
memory: 29096kb

input:

99999 10 199991 1200882200
13258 42015 683121709
97263 83047 508739550
43513 76902 177620965
99103 54900 750592886
36304 66562 981946527
81556 64446 642835412
54198 24510 96066425
60283 60871 951723705
81968 35708 27719918
47846 42345 14875785
3760 64190 376263792
20533 85486 3
76749 10379 164456056...

output:

1508583135

result:

ok single line: '1508583135'

Test #147:

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

input:

99995 10 199990 1199509820
90475 63168 470796315
76906 57373 959999641
6043 15518 611376690
8080 12183 993250871
32349 77150 585630342
28921 47950 289663529
21085 42877 966329107
42266 35135 652530190
95635 33847 884626939
27182 38933 972213538
43929 95405 6
51390 5567 7
55702 55702 112406218
45247 ...

output:

1469612326

result:

ok single line: '1469612326'

Test #148:

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

input:

10 10 200000 4
4 9 321325765
9 1 437057496
6 5 985769268
3 9 50382707
9 4 616260423
2 8 570642446
5 4 105891394
8 4 898479132
6 4 21194991
10 9 160126166
10 4 126634623
8 3 616764966
6 3 193643546
3 6 976742333
5 3 206532267
5 9 339534940
2 5 68957761
3 2 338656904
4 3 209030635
8 1 413660186
6 4 17...

output:

11055

result:

ok single line: '11055'

Test #149:

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

input:

10 10 200000 20
4 4 395366511
5 8 382893539
6 10 734921426
4 1 480608782
1 3 140698066
1 8 275345561
9 9 818353946
7 10 722563406
8 4 403315816
7 3 428052136
9 6 365851244
2 4 136417674
1 9 221184959
10 10 657301036
10 4 780862366
5 4 420227323
2 6 250951556
8 5 710603299
4 5 802180680
3 1 725989581...

output:

56218

result:

ok single line: '56218'

Test #150:

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

input:

300 10 200000 12
158 273 808659230
102 35 507820985
170 272 203017365
289 129 122315598
170 137 940036704
263 263 548010497
289 172 433876938
263 129 104073946
137 102 274468171
272 272 108045360
164 57 104459600
75 260 345914842
164 133 103121843
115 219 172719623
240 202 326093473
43 277 24661061
...

output:

37079

result:

ok single line: '37079'

Test #151:

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

input:

300 10 200000 3526
3 201 649407852
97 179 793983104
176 201 109766918
88 130 642979450
176 33 527751678
97 140 728819427
176 3 691935221
97 140 844254278
59 176 10173621
59 198 295910606
100 13 591999205
276 147 959642104
103 156 279544444
88 268 673183712
11 50 679477490
178 167 193754627
134 143 8...

output:

885439

result:

ok single line: '885439'

Test #152:

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

input:

199999 3 199999 157505
131899 131899 121038207
78492 24185 788537289
116632 40406 784568458
185511 129310 767314798
51376 72237 579146077
24328 179828 841955884
174135 183337 366530487
13116 141076 512880711
176967 63206 153598548
36532 129034 588969313
49389 168370 454188410
3067 123598 203306371
3...

output:

306266673

result:

ok single line: '306266673'

Test #153:

score: 0
Accepted
time: 156ms
memory: 54852kb

input:

199999 4 199999 6947016393
40612 148109 997371971
134967 144753 510854619
162271 179843 808938622
188200 49534 756911179
17103 79943 239088038
82030 76059 523665726
33678 55856 199390684
182910 144316 745104020
60233 151657 956651453
60948 64516 535905852
141929 142738 232494743
50351 97972 37976623...

output:

754800722

result:

ok single line: '754800722'

Test #154:

score: 0
Accepted
time: 184ms
memory: 57596kb

input:

199999 5 199999 19999700001
47117 120852 940132990
1765 172575 689125947
1765 161815 568449078
89806 89806 164455745
34861 47117 290568041
149579 53706 763885240
25053 172888 645267817
145285 123816 22925532
61547 81596 585729464
122633 129413 452896022
174862 47042 482017495
120597 174583 743525680...

output:

-1

result:

ok single line: '-1'

Test #155:

score: 0
Accepted
time: 103ms
memory: 44644kb

input:

199999 6 199999 1677
104258 166054 19
101504 166054 53
68830 93374 65
166054 151410 16
145922 151410 86
68830 151410 62
86977 41289 44
18109 61358 78
85856 38506 35
30318 73191 20
125715 108222 40
7906 65451 29
128960 42088 79
33180 92662 39
835 111123 97
45915 84947 39
140077 149859 46
28611 80228 ...

output:

1

result:

ok single line: '1'

Test #156:

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

input:

199999 7 199999 3022023130
93862 12459 87
197095 54284 30
138491 12459 3
146624 169676 45
83465 147937 18
118062 54284 48
132418 175897 15
68485 7440 17
193831 117622 94
161569 168074 76
110839 16622 68
156150 99998 50
114603 1320 56
173855 50908 44
173651 64525 98
46701 32466 84
100453 27335 80
153...

output:

64

result:

ok single line: '64'

Test #157:

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

input:

200000 10 100000 5070918
43491 43491 39
102413 48280 41
191112 39650 21
43491 56371 90
123486 57685 61
191112 127146 81
127146 43491 45
194858 57685 6
102413 48280 63
183969 127146 19
114853 187622 592818998
23880 38803 866309656
159168 94973 182921889
12700 152040 605888341
97124 99493 193911122
88...

output:

994309314

result:

ok single line: '994309314'

Test #158:

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

input:

200000 8 87 6764
58199 178940 398283482
90018 134936 884790211
90018 35304 510188463
160878 177880 899791863
35304 24561 37085435
160878 178940 512659808
24561 24561 661205664
58199 24561 707748395
185561 127022 89
65334 173029 15
53986 45438 31
89818 139186 47
148119 24466 80
153186 135546 1
20066 ...

output:

-1

result:

ok single line: '-1'

Test #159:

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

input:

200000 9 103 1855
102649 8113 556125025
2417 22645 479236739
145556 159349 874101574
125704 2417 947240213
159349 16814 435825424
125704 159349 458608368
102649 125704 376755733
125704 167325 266275655
41973 161268 746376426
94793 866 15
129759 175440 93
157036 63464 26
65233 120770 50
153494 159437...

output:

-1

result:

ok single line: '-1'

Subtask #4:

score: 8
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #160:

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

input:

1 0 0 0

output:

0

result:

ok single line: '0'

Test #161:

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

input:

2 0 0 1

output:

-1

result:

ok single line: '-1'

Test #162:

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

input:

2 200000 200000 1
2 1 219389047
2 2 613563872
2 2 355040326
1 1 462927610
1 1 891925404
1 2 342545178
1 1 34440231
2 2 275850948
1 1 660347755
1 1 408080917
2 2 678432438
1 2 399161541
2 2 621748646
1 2 485177233
2 1 940507905
1 1 216794513
1 2 979502352
1 2 979616556
2 1 145029400
2 1 72051793
2 1 ...

output:

3097

result:

ok single line: '3097'

Test #163:

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

input:

2 200000 200000 1
2 2 1000000000
2 1 1000000000
1 1 1000000000
1 1 1000000000
2 1 1000000000
1 1 1000000000
1 2 1000000000
1 2 1000000000
1 2 1000000000
2 1 1000000000
1 2 1000000000
1 2 1000000000
2 1 1000000000
1 2 1000000000
2 1 1000000000
2 1 1000000000
1 1 1000000000
2 1 1000000000
2 2 10000000...

output:

1000000000

result:

ok single line: '1000000000'

Test #164:

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

input:

200000 0 200000 494377
135101 196696 828081199
86262 169437 503646193
152150 1265 923172322
181844 157014 117294115
180111 40623 105095402
96355 125547 543371693
62782 115550 365484387
65951 152594 635090651
190916 57076 746847421
96239 51393 615803704
196216 182569 801160439
132962 166167 801688391...

output:

418718169

result:

ok single line: '418718169'

Test #165:

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

input:

200000 200000 0 1231595
115915 54374 111510075
108656 166040 943764211
180002 64807 404953514
50773 51218 407519005
126979 150607 913308520
30446 52932 627767745
11990 38049 104329788
68777 78661 621110830
119495 137010 149791953
139949 112322 736345121
90177 46512 275805344
185954 109022 993064790
...

output:

470628779

result:

ok single line: '470628779'

Test #166:

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

input:

200000 200000 200000 19999900000
197379 16682 123723
88948 157855 93328
54855 24111 44724
190317 145293 4918
85952 39934 45159
112774 84140 119473
73550 121691 107265
102903 113557 130917
180366 130226 154034
132114 197390 175580
72923 185974 78453
41894 142599 28985
108403 18127 35695
101269 147777...

output:

199999

result:

ok single line: '199999'

Test #167:

score: 0
Accepted
time: 240ms
memory: 61876kb

input:

200000 200000 200000 19999900000
84612 93301 92319
27668 52032 139410
110087 112811 110952
192157 183036 156494
100959 45053 91958
29255 77531 64499
54891 16064 104691
8890 183628 35323
153966 123939 133734
133752 55470 195326
129690 116083 3362
138107 72168 19292
185532 69927 78149
98828 459 152001...

output:

199999

result:

ok single line: '199999'

Test #168:

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

input:

200000 200000 200000 19999900000
32959 43344 171639
71279 23697 126158
48672 101245 113652
5061 115209 174142
44176 135267 199289
154555 47208 15129
119125 134199 132253
181489 110978 14700
27888 175267 107797
99954 34116 27968
37247 171414 41683
124347 91449 171354
21914 163398 47094
16053 150594 1...

output:

199999

result:

ok single line: '199999'

Test #169:

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

input:

200000 200000 200000 19999900000
38069 160051 151290
88143 185872 136639
154271 72247 31963
29377 106037 71005
158582 71627 71149
85873 186291 53395
44835 168624 89361
81061 48982 138394
77446 65031 132983
128854 12412 18459
105197 78452 2650
35155 145236 30067
75361 121391 173165
14708 133072 12479...

output:

200000

result:

ok single line: '200000'

Test #170:

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

input:

200000 0 0 0

output:

0

result:

ok single line: '0'

Test #171:

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

input:

200000 0 0 1

output:

-1

result:

ok single line: '-1'

Test #172:

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

input:

200000 0 0 19999900000

output:

-1

result:

ok single line: '-1'

Test #173:

score: 0
Accepted
time: 323ms
memory: 73088kb

input:

200000 200000 200000 0
71756 108365 64605185
49792 63849 859109385
70587 7044 841370391
120607 148403 235877393
119476 85623 79695289
128693 97597 282095822
96656 99219 754659736
138564 159903 783046645
78443 111635 212112889
113464 78918 98888098
139885 109066 585039138
113568 63693 398318073
79661...

output:

0

result:

ok single line: '0'

Test #174:

score: 0
Accepted
time: 334ms
memory: 74296kb

input:

200000 200000 200000 1
155072 157532 418145282
175884 65090 267277282
7205 25713 913410840
3180 53533 805553609
157011 48065 963869014
6422 94943 196881443
147621 185661 636073657
25515 111544 763147959
86699 54686 191855915
102332 54396 269890807
7777 199710 382109273
40513 68917 874417036
2092 156...

output:

126

result:

ok single line: '126'

Test #175:

score: 0
Accepted
time: 341ms
memory: 72856kb

input:

200000 200000 200000 8
1788 108807 313624334
14859 129146 437260556
186675 30765 317265735
137010 193076 30068971
110131 58427 871131839
193993 44254 126231688
184624 30397 418885966
154208 126122 989943905
171221 15976 386261496
184523 106780 818826264
194209 182618 584423005
108165 54461 765173160...

output:

27263

result:

ok single line: '27263'

Test #176:

score: 0
Accepted
time: 326ms
memory: 73600kb

input:

200000 200000 200000 38
90501 73603 79886890
81680 186744 826354669
189870 633 736506488
20437 4988 611273893
14888 79258 649080647
196903 41986 407959518
93675 123642 233857763
27871 196405 164634515
49644 69743 954443827
70996 111192 147132584
80563 144446 688516486
151398 17703 635967231
4461 577...

output:

151694

result:

ok single line: '151694'

Test #177:

score: 0
Accepted
time: 328ms
memory: 73484kb

input:

200000 200000 200000 596
138923 186056 320058188
162110 177231 895237424
165665 196102 597817060
110762 177173 173800190
60254 118494 772786762
51368 129378 361690172
19449 81435 932511758
94577 140393 666887969
97011 124715 324785169
68271 103267 890620096
162281 19398 480300716
118309 93136 104398...

output:

2823482

result:

ok single line: '2823482'

Test #178:

score: 0
Accepted
time: 329ms
memory: 74576kb

input:

200000 200000 200000 7593
51599 59391 686745005
46172 123201 596309899
148485 6891 438569602
29665 64340 153213565
42945 110242 517131189
17110 54419 61696950
194147 30563 85545909
44916 101563 594273504
162797 51889 23839193
129248 106299 321736142
51415 116521 868143648
75374 199401 950574132
1805...

output:

35234383

result:

ok single line: '35234383'

Test #179:

score: 0
Accepted
time: 394ms
memory: 79336kb

input:

200000 200000 200000 909662
14328 135186 524203740
154064 143936 534393415
28747 117247 917321658
188313 94905 402047888
161167 117233 315935843
11913 187010 935295957
29687 194341 807081821
129067 104124 878650679
97369 4080 124397895
46372 92255 903920189
121430 25708 701649266
120112 8136 6394201...

output:

451731374

result:

ok single line: '451731374'

Test #180:

score: 0
Accepted
time: 422ms
memory: 79988kb

input:

200000 200000 200000 36525928
56013 46244 927918572
179759 99201 506541094
132928 124730 557060306
165581 157678 50838290
104465 98003 539337584
8211 166183 462863729
71172 197459 278393658
64901 63722 595905731
173715 72542 206346269
143187 104294 202940892
149439 189261 626945332
145299 115020 882...

output:

507425760

result:

ok single line: '507425760'

Test #181:

score: 0
Accepted
time: 433ms
memory: 81664kb

input:

200000 200000 200000 1225658813
92656 189542 180872972
172879 112496 355684369
9850 111079 866179693
95441 15161 715995937
53881 174818 886532343
197300 66476 690139205
68303 113303 913996611
16055 36419 990203218
185530 164758 469531620
61624 122870 228027761
54695 169342 261796095
56365 188158 160...

output:

574088600

result:

ok single line: '574088600'

Test #182:

score: 0
Accepted
time: 401ms
memory: 69964kb

input:

200000 200000 200000 19999900000
106441 73871 966631793
163716 167688 935535321
7142 5880 593638764
161816 196693 892005058
95217 126510 472343313
79477 198394 617842633
33995 108002 358007749
170170 51030 533447238
23089 17931 649173020
107028 21493 689127478
128536 160828 625810676
184650 120304 5...

output:

-1

result:

ok single line: '-1'

Test #183:

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

input:

200000 200000 200000 0
33947 2612 925712177
164925 66021 312158647
105229 125091 64947024
14171 155958 763922004
49000 177701 666898473
122290 37082 619894258
123315 161926 738821329
144983 94616 563549977
42922 17139 448750132
104554 136476 751113806
24121 94911 477841171
127039 43107 673348777
953...

output:

0

result:

ok single line: '0'

Test #184:

score: 0
Accepted
time: 336ms
memory: 72304kb

input:

200000 200000 200000 1
84309 153489 999728
108031 56090 823843229
136371 11952 477674712
71855 171570 383241482
147718 78298 527960332
107390 27842 927478889
85942 181978 420310493
27820 197874 5721114
140464 69431 268729781
19700 176706 295350337
116539 70097 820075540
185927 32560 144229006
24760 ...

output:

2

result:

ok single line: '2'

Test #185:

score: 0
Accepted
time: 335ms
memory: 73352kb

input:

200000 200000 200000 4
169502 64840 959399259
74959 177432 16677394
77189 18633 20296017
114903 54378 630256297
151175 14950 538284943
154411 20947 309891221
40392 108867 876885107
72506 44242 774413585
165995 118693 386045427
114324 143947 474188946
196591 34210 70950853
152523 97745 191751291
4949...

output:

23

result:

ok single line: '23'

Test #186:

score: 0
Accepted
time: 315ms
memory: 73876kb

input:

200000 200000 200000 23
56483 99699 888323311
70228 15950 741764601
72644 111730 424724644
125881 137738 610094171
112624 192453 209649798
71834 15037 650747666
33802 44769 934544065
192327 12796 172177171
18117 153847 756926900
51537 158093 404691881
183392 93524 966032643
4370 166378 405176180
337...

output:

14

result:

ok single line: '14'

Test #187:

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

input:

200000 200000 200000 840
889 20197 661402027
179336 108690 546804089
54064 787 153763285
55760 150811 497748089
65798 57441 667910522
52793 19914 427929858
107648 64761 819047384
9536 59872 20767978
195420 92802 718626935
57679 36509 558183524
115312 159279 777252572
151324 172997 104916287
63333 54...

output:

82

result:

ok single line: '82'

Test #188:

score: 0
Accepted
time: 326ms
memory: 74156kb

input:

200000 200000 200000 4610
115062 4053 226228536
33456 90871 340348713
98794 185648 620485730
6022 107145 572157699
131135 121719 204918664
130163 154026 68
66668 152925 484547245
113961 80940 77
127726 73781 453886368
190440 141102 507767922
158869 132584 447007544
171861 189273 47
131622 42416 4316...

output:

44

result:

ok single line: '44'

Test #189:

score: 0
Accepted
time: 370ms
memory: 75460kb

input:

200000 200000 200000 130518
149683 56866 636896655
95243 150520 225325122
12186 118199 352740913
168440 118200 98
102098 73091 62
100556 72271 295009427
32269 142982 93
84995 123902 9431371
145543 177347 64
168220 15 38
53092 86551 92
71557 35907 85
40441 11515 89
158416 43300 921509554
159906 95019...

output:

57

result:

ok single line: '57'

Test #190:

score: 0
Accepted
time: 411ms
memory: 80632kb

input:

200000 200000 200000 27804399
103408 88397 346244
5360 187929 88
9301 64113 9
6957 120295 191114740
126875 129837 99
10789 198947 530517280
6872 113826 42
44595 129108 138905475
123685 179637 162700682
32533 143006 636021287
16721 144046 582850658
119985 49922 45
142694 116974 913235571
31138 167450...

output:

3934586

result:

ok single line: '3934586'

Test #191:

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

input:

200000 200000 200000 8268591972
45184 185441 631731257
99240 18356 67
34457 157168 37
14020 40365 23
120875 181348 52
70227 142540 40771905
48525 150564 576490742
38162 164016 59885413
69154 19393 50
69037 161001 780721730
181835 167408 96
86202 178567 38
151922 37416 25
11250 15646 729747629
80987 ...

output:

599541714

result:

ok single line: '599541714'

Test #192:

score: 0
Accepted
time: 388ms
memory: 71208kb

input:

200000 200000 200000 19999900000
112716 18863 948823922
185547 105670 604765812
21971 16376 944215783
121540 167985 437383994
152308 171280 490254764
103951 164712 644935712
166241 182533 79
134051 14658 75
130013 56329 74
11523 172042 64
135049 19883 5
676 111087 427518644
107470 199622 25
198506 1...

output:

-1

result:

ok single line: '-1'

Test #193:

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

input:

99995 199991 199994 1248185078
9304 2456 3
14990 98173 9
78704 1679 10
77962 57257 368369575
24422 35238 774851856
99355 98691 8
59218 24475 10
87858 33844 5
89054 94919 672953922
98706 18285 585711613
86024 86 434243552
75088 19205 5
93450 99000 6
81651 84986 78322276
92639 88252 8
19337 12660 9890...

output:

411395088

result:

ok single line: '411395088'

Test #194:

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

input:

99996 199992 199993 1248227922
45122 27161 643892901
97560 61481 678114038
1395 7507 2
73015 54887 102392204
73765 54533 770833708
90236 82144 6
56247 19741 539566043
99328 29540 8
40057 16546 273369500
64074 87634 543872289
4390 71915 696328338
98806 69395 1
36799 73447 2
71261 8520 5
51969 9758 43...

output:

85516850

result:

ok single line: '85516850'

Test #195:

score: 0
Accepted
time: 197ms
memory: 36240kb

input:

99997 199993 199992 1247959641
42784 39901 1
29169 51806 567297395
67580 83272 499131004
76747 49972 3
44374 37845 213725617
84002 87271 907900518
12459 57323 453835497
63835 3434 4
86800 40638 472233360
8767 92388 5
82517 1180 9
434 44193 708918643
9423 18416 3
72919 63640 5
56127 59769 916754732
8...

output:

10733105

result:

ok single line: '10733105'

Test #196:

score: 0
Accepted
time: 197ms
memory: 35876kb

input:

99998 199994 199991 1248278066
63228 74477 10
71744 11993 2
4632 63888 8
9928 40555 7
26347 43207 844826610
73817 17123 3
97858 86377 8
62648 66661 1
58912 6970 6
45979 10366 400726683
79700 93773 748968889
86662 83889 2
86082 17108 273166730
67787 55727 3
22784 81902 5
50214 50214 999138797
2483 24...

output:

932952

result:

ok single line: '932952'

Test #197:

score: 0
Accepted
time: 237ms
memory: 37068kb

input:

99991 199990 199994 4853468901
5301 35901 857612061
56183 95055 450495062
36194 86890 47112804
45493 65315 737374130
51641 67546 283822921
9616 24376 105128179
20148 48503 524386265
69461 3417 522238614
14651 25825 754747698
80293 88654 483890715
19394 71179 929255799
63808 14982 334249412
82286 179...

output:

1999440160

result:

ok single line: '1999440160'

Test #198:

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

input:

99997 199991 199993 4850344650
91635 68979 284219447
17071 66168 775452730
69421 27513 57627437
97143 83493 341257458
51859 18507 785777746
20733 3624 560736636
38990 5683 344472094
4218 36403 829332646
53128 54438 526722865
32216 46376 898552650
9541 93564 862032383
99815 9601 473172907
97678 54690...

output:

1997807187

result:

ok single line: '1997807187'

Test #199:

score: 0
Accepted
time: 227ms
memory: 37224kb

input:

99993 199992 199992 4849633740
23291 11264 956742709
54076 15748 337544366
36487 51655 668034354
99818 1192 21013754
45333 40611 440425394
48646 8266 63760296
48665 25116 325792671
39630 48410 25379233
85728 16648 39321805
63393 27294 1118684
5541 40338 707992046
94658 6834 721834173
51020 41817 627...

output:

1998036708

result:

ok single line: '1998036708'

Test #200:

score: 0
Accepted
time: 213ms
memory: 37176kb

input:

99999 199993 199991 4850087332
30201 33236 942448023
97797 56347 373576614
62190 77780 718744243
53256 35283 828821272
18293 6199 878237957
65480 90080 75230242
59792 68258 218893285
8387 87574 541388616
32158 47112 396491818
4414 75621 280012237
29937 84481 486853686
67123 65783 248349526
19025 395...

output:

1998628527

result:

ok single line: '1998628527'

Test #201:

score: 0
Accepted
time: 227ms
memory: 38140kb

input:

99995 199994 199991 4854113750
9811 5081 351818104
81846 60840 80667988
32931 22214 502918712
48163 79269 693246465
8496 80801 392580441
35459 68460 614779709
82912 79545 358626216
70604 13361 449101919
23726 39314 810343014
93886 28181 36363401
60918 30315 121570663
62680 4466 161366196
18540 39318...

output:

1999490615

result:

ok single line: '1999490615'

Test #202:

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

input:

10 200000 200000 9
2 4 402668946
9 2 138273132
5 3 765622167
1 3 571869358
9 3 50869392
8 10 388144462
2 4 939391177
9 6 202357683
9 3 379012564
10 3 117030752
6 2 428703406
2 9 430885375
8 5 440399845
7 10 538295318
4 10 44945403
1 5 662196965
9 1 642218476
3 3 573785396
4 4 912291740
1 7 730518871...

output:

15270

result:

ok single line: '15270'

Test #203:

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

input:

10 200000 200000 45
9 3 920254800
4 5 481541668
9 4 751303369
2 1 997614613
4 7 903011694
2 5 976683507
3 3 204366253
4 9 474158003
1 1 205379734
5 6 129033907
4 9 902699521
6 1 851798564
6 3 461853664
9 1 813822917
8 7 383306125
2 1 874008656
3 10 447573734
1 5 4083028
8 1 243396553
9 8 201892006
4...

output:

51271

result:

ok single line: '51271'

Test #204:

score: 0
Accepted
time: 87ms
memory: 6052kb

input:

300 200000 200000 102
89 1 768250093
158 248 701317711
289 19 781174193
27 59 685212346
194 160 362622942
283 202 991291438
131 19 50195423
96 223 300880504
206 181 7237896
9 73 57644432
136 98 255301465
131 247 306577689
57 185 526322149
161 47 100374334
29 93 756215
268 123 790555282
155 98 278914...

output:

291990

result:

ok single line: '291990'

Test #205:

score: 0
Accepted
time: 88ms
memory: 5996kb

input:

300 200000 200000 13904
275 116 360416650
99 8 572246317
148 47 315636548
62 249 446776688
17 231 707263973
9 24 963328337
228 229 254590930
153 210 968663255
14 46 552346146
216 47 434173232
75 278 854185181
196 268 910335100
288 184 534768557
144 76 80149478
14 239 690437444
55 164 161014114
150 2...

output:

1045436

result:

ok single line: '1045436'

Test #206:

score: 0
Accepted
time: 364ms
memory: 75984kb

input:

199999 199999 199999 139869
25003 172292 143302165
199131 108372 230702882
51808 113806 803490332
194046 54070 353758268
19673 46168 188839202
41698 122162 400825019
105452 129409 551754346
148360 67873 657213322
118089 54341 648132602
67690 120420 393335446
76647 45469 570092525
41300 100144 961593...

output:

289549242

result:

ok single line: '289549242'

Test #207:

score: 0
Accepted
time: 419ms
memory: 78036kb

input:

199999 199999 199999 5154745235
46117 5272 460447836
515 22623 573653514
10750 84633 638497423
90901 111871 478156935
104063 58035 135180746
69912 36826 578791651
32313 183648 152949838
90123 189863 630396564
963 118142 450780120
142760 187033 756965995
21374 99516 277009260
135021 177142 516922968
...

output:

694517600

result:

ok single line: '694517600'

Test #208:

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

input:

199999 199999 199999 19999700001
68287 186636 205314677
106778 73480 199912109
151710 14283 173925106
54054 154191 28662105
98968 181706 49934045
169046 113062 79084400
32432 65731 259742353
59527 58789 503748089
89774 86331 462583421
119781 98428 493263299
173933 83828 650765066
26820 173722 519157...

output:

-1

result:

ok single line: '-1'

Test #209:

score: 0
Accepted
time: 355ms
memory: 77608kb

input:

199999 199999 199999 196916
38421 161634 3
42371 93592 39
44504 28879 11
13561 198881 46
58890 114746 65
7765 89087 65
100878 1430 66
4520 160736 44
76405 51677 35
40167 74154 7
101713 123968 81
151031 95844 88
121883 150420 22
34692 176068 53
132780 199235 17
154905 65071 24
20355 4808 88
89864 144...

output:

34

result:

ok single line: '34'

Test #210:

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

input:

199999 199999 199999 16652506862
37267 5336 70
43747 186741 32
174750 61917 63
20394 39134 29
101800 148931 86
87490 94390 38
45177 169711 14
196402 146634 78
70018 80202 58
191739 28820 92
197416 114984 59
1097 171006 42
188178 54505 57
199418 79740 44
105362 134592 31
122989 57792 97
126725 73824 ...

output:

191

result:

ok single line: '191'

Test #211:

score: 0
Accepted
time: 227ms
memory: 54120kb

input:

200000 100000 100000 8041148
29971 6924 214607301
41603 41652 879454669
144412 508 315123951
190181 79376 963184783
97363 176336 780663073
41706 142121 272634087
174985 144251 397529095
95243 173326 778740556
177041 22974 168131723
188518 50726 222139777
169418 69394 969114345
40596 67746 899366509
...

output:

1961673757

result:

ok single line: '1961673757'

Test #212:

score: 0
Accepted
time: 243ms
memory: 58168kb

input:

200000 200000 87 1989
15417 147283 128576416
88997 33357 576856999
199902 9318 66311044
133307 100495 324693745
64017 178705 37630119
35203 111685 681211267
8029 138157 614832424
147442 70497 950522417
51618 69938 480408858
40531 194081 587621668
157824 184815 609197841
80870 194186 567846160
132269...

output:

8882042

result:

ok single line: '8882042'

Test #213:

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

input:

200000 103 199999 3122
17865 136931 46
169868 53126 71
75142 93011 52
56255 53370 53
185961 64858 33
180609 149901 43
152375 57859 49
49349 65162 35
73662 111881 44
150000 165573 96
34949 63959 98
26716 123643 2
155121 61873 74
197449 100429 60
51396 127146 99
74524 45251 89
54371 77807 96
142011 16...

output:

14326196

result:

ok single line: '14326196'

Extra Test:

score: 0
Extra Test Passed