QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#112484#5648. Crossing the RailwayslarryzhongAC ✓307ms12736kbC++174.0kb2023-06-12 00:57:402023-06-12 00:57:41

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3308kb

input:

4 3 5 1
1 2 1
3 4 1
2 3 2
3 4 3

output:

0

result:

ok single line: '0'

Test #2:

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

input:

3 3 12 2
2 10 1
1 6 2
8 12 3

output:

2

result:

ok single line: '2'

Test #3:

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

input:

8 4 13 2
1 4 1
5 13 1
1 5 2
6 13 2
1 9 3
10 13 3
1 10 4
11 13 4

output:

2

result:

ok single line: '2'

Test #4:

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

input:

1 1 2 2
1 2 1

output:

-1

result:

ok single line: '-1'

Test #5:

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

input:

10 7 85 8
76 89 7
22 36 6
17 61 4
62 96 3
57 86 6
51 94 5
39 40 1
31 39 7
7 18 5
67 87 4

output:

-1

result:

ok single line: '-1'

Test #6:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

10 3 99994 12436
14053 20692 1
20693 72913 1
1 14052 1
36226 100000 3
1 5048 2
1 688 3
70945 100000 2
5049 70944 2
72914 100000 1
689 36225 3

output:

-1

result:

ok single line: '-1'

Test #8:

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

input:

10 7 67853 3238
27043 44174 4
69150 89334 2
65082 73038 1
18887 34795 6
49387 76379 7
63582 76311 4
70393 78225 6
52699 81352 5
79076 90480 6
46727 51948 4

output:

0

result:

ok single line: '0'

Test #9:

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

input:

10 10 99991 6429
1 100000 6
1 100000 3
1 100000 7
1 100000 5
1 100000 8
1 100000 10
1 100000 4
1 100000 2
1 100000 1
1 100000 9

output:

-1

result:

ok single line: '-1'

Test #10:

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

input:

100 1 21964 5206
64259 64277 1
11354 11400 1
59905 60165 1
65204 65413 1
56524 57796 1
29791 30173 1
70653 71198 1
93335 93420 1
24188 25637 1
23637 23656 1
92593 92888 1
27676 27903 1
98254 98347 1
25867 26233 1
98617 98915 1
81799 82593 1
65830 65833 1
90917 91368 1
85545 85824 1
12460 12801 1
949...

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 3ms
memory: 3408kb

input:

100 10 99993 807
44838 54767 6
34286 35646 5
57765 65793 2
28816 31503 6
17001 28771 10
34266 37715 8
1 701 3
96466 96997 2
72476 96463 10
17723 31765 4
36014 80395 4
81278 100000 9
35980 50283 2
81069 90828 8
21774 51612 7
49735 52230 9
61622 83904 6
38580 44837 6
52288 85556 1
90564 95262 7
12874 ...

output:

6

result:

ok single line: '6'

Test #12:

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

input:

500 10 1000000000 2
142857144 285714285 9
428571398 441558409 8
505154624 515463901 7
844155782 857142793 8
615384610 653846147 5
333333335 666666667 3
286821634 290697601 10
649350602 662337613 8
829457154 833333121 10
643410690 647286657 10
879844738 883720705 10
980619906 984495873 10
232558082 2...

output:

-1

result:

ok single line: '-1'

Test #13:

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

input:

100 10 100000000 1
65384586 67307661 10
66666666 83333331 7
41176466 47058817 8
1923078 3846153 10
64705874 70588225 8
50000000 66666665 7
24999990 26923065 10
70000002 80000001 9
29411762 35294113 8
44230750 46153825 10
1 50000001 1
7692306 9615381 10
78846118 80769193 10
47058818 52941169 8
1 5882...

output:

-1

result:

ok single line: '-1'

Test #14:

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

input:

500 9 999999999 2
657608624 660326014 1
100543469 103260859 1
666666668 999999999 7
16304348 19021738 1
499999973 509803893 2
441176447 450980367 2
119565206 122282596 1
638586887 641304277 1
598039183 607843103 2
105978251 108695641 1
603260804 605978194 1
911764655 921568575 2
215686264 225490184 ...

output:

-1

result:

ok single line: '-1'

Test #15:

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

input:

500 10 1000000000 2
914728450 918604417 1
740309890 744185857 1
426356482 430232449 1
864340866 868216833 1
155038722 158914689 1
19379842 23255809 1
662337614 675324625 3
806201346 810077313 1
230769230 269230767 6
680412350 690721627 4
730769224 769230761 6
666666668 1000000000 8
480519446 4935064...

output:

-1

result:

ok single line: '-1'

Test #16:

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

input:

499 9 999999999 1
269340928 272206256 1
880597009 895522381 6
252148954 255014282 1
564469815 567335143 1
151862439 154727767 1
183381058 186246386 1
805157451 808022779 1
916905282 919770610 1
381088759 383954087 1
744985542 747850870 1
830945412 833810740 1
111747833 114613161 1
366762114 36962744...

output:

5

result:

ok single line: '5'

Test #17:

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

input:

500 10 1033 1
146 147 9
425102045 426278607 10
7 8 5
172 173 9
491288680 492577580 2
492751805 495141421 2
406883925 407729331 8
430916577 439194148 10
53 54 7
285486924 288710420 10
492280745 492365570 6
364681721 369045569 6
257 259 9
527151480 530848869 2
627023308 631305186 6
6602533 6761587 6
6...

output:

6

result:

ok single line: '6'

Test #18:

score: 0
Accepted
time: 7ms
memory: 3392kb

input:

500 9 520 1
722258468 729328450 4
28747983 28771374 2
488348273 503008474 6
518687400 525432288 6
94 98 9
15 18 7
917690835 920808436 4
11 12 7
183465079 187632727 6
231 232 9
872330615 878322520 6
720434962 732801123 6
76149585 79469009 2
711362690 713979285 6
238766525 244348647 6
843948471 854631...

output:

5

result:

ok single line: '5'

Test #19:

score: 0
Accepted
time: 9ms
memory: 3376kb

input:

500 8 263 1
332967814 333854913 2
193964921 193989285 8
920298727 921947250 4
611396553 621673317 2
633900936 634127098 6
742318370 749799022 2
723565336 725111631 2
17 34 5
567617404 578161367 6
954324010 958726400 8
210890274 214112347 4
60 61 7
696544594 697972465 2
23690559 26068843 2
227004170 ...

output:

5

result:

ok single line: '5'

Test #20:

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

input:

500 5 36 1
736525096 737176072 2
826065526 826420915 2
575539457 577067694 4
464195410 467776687 4
102216431 104351723 2
595513604 596211594 2
249247876 250229490 2
933407076 934827676 2
114071197 116685931 4
393380617 393719180 4
571542510 573494864 4
13 14 5
895041107 897734374 2
627642914 6279156...

output:

3

result:

ok single line: '3'

Test #21:

score: 0
Accepted
time: 3ms
memory: 3424kb

input:

500 4 19 1
988249321 989151075 2
24914992 27551677 2
61287600 61649179 2
521128327 523216880 4
41003949 42365401 4
471627184 473119237 2
618019429 621913945 4
700776574 701601370 2
344009688 346358179 4
999580471 1000000000 2
243988095 245771034 4
637748766 638912743 4
842055602 842096510 2
72343264...

output:

3

result:

ok single line: '3'

Test #22:

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

input:

500 2 5 1
703552090 704373043 2
336315929 338391052 2
235153239 235416592 2
386534436 386725183 2
903287865 903363623 2
844712694 845744336 2
533127630 536029456 2
15671424 16551215 2
714401772 715160703 2
9830775 9901730 2
258389301 259393067 2
309628316 310902908 2
334824652 336076919 2
99629072 9...

output:

1

result:

ok single line: '1'

Test #23:

score: 0
Accepted
time: 10ms
memory: 3376kb

input:

500 10 689 1
171676435 174427736 10
975389257 983427756 8
81487451 85456841 10
117857902 118136898 2
270802098 271041547 8
729513506 736000195 2
965359041 967378757 2
245203765 246792393 6
724186000 728274474 10
94230217 100594937 2
62615977 68191044 10
15658619 15770256 2
617912518 642525377 2
3610...

output:

10

result:

ok single line: '10'

Test #24:

score: 0
Accepted
time: 9ms
memory: 3432kb

input:

500 9 176 1
555978650 572852034 2
985447299 990927247 4
417885668 422429105 6
807548956 816006206 6
273645265 273837165 4
763521425 773347922 4
296241107 306463177 4
803937721 807357999 6
902007356 926774901 8
161047191 164441520 8
809248384 809496304 8
728953348 731315010 8
931366233 933489746 6
48...

output:

8

result:

ok single line: '8'

Test #25:

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

input:

500 8 176 1
150724535 150812877 4
332967814 333854913 2
559070267 563638077 4
46 1000000000 7
824895413 826608476 6
42067111 52370955 2
678136095 679835000 4
71774505 82727539 2
966343388 966603045 4
478222775 485775420 8
549078408 549576557 6
869625115 889692170 8
281597391 283510221 4
156946936 16...

output:

8

result:

ok single line: '8'

Test #26:

score: 0
Accepted
time: 9ms
memory: 3376kb

input:

500 6 47 1
553411492 555754525 4
701684001 702570509 2
789619517 789986905 4
588792556 595115005 6
1 12 5
903651069 906670007 6
284263413 286110589 2
623438976 624588719 6
883130171 889548515 2
214948275 214978531 2
102587694 105491804 4
977487953 978478293 6
989614121 989990473 2
87154181 94118383 ...

output:

6

result:

ok single line: '6'

Test #27:

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

input:

500 4 14 1
761434021 762165778 4
41213945 41642992 2
282133902 283095099 2
253390369 253662715 4
694279574 697374848 2
40920346 42121471 4
86468278 89423460 4
332653773 332822131 2
975011003 975150963 2
905420357 906501874 4
58395916 58632287 2
348845785 352396178 4
531392906 533700610 2
421591148 4...

output:

4

result:

ok single line: '4'

Test #28:

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

input:

500 3 5 1
601790893 602553122 2
462015179 463589192 2
903180614 903618270 2
276127854 276212993 2
18257584 18769091 2
239449321 240222628 2
588062826 591457530 2
158993850 159392473 2
708918695 709744909 2
225109342 225399378 2
344189487 345157840 2
252361347 253664854 2
970471810 973025356 2
605271...

output:

2

result:

ok single line: '2'

Test #29:

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

input:

500 10 1990 172
500 525 5
1412 1420 7
1675 1695 4
1967 1988 1
1368 1405 3
795 797 8
501 543 6
939 1028 9
197 199 1
1421 1470 7
1404 1444 1
74 86 1
1535 1548 4
1847 1869 4
228 244 4
385 389 3
1327 1329 7
1528 1605 3
1034 1035 3
194 222 6
21 111 6
1233 1256 2
1451 1485 2
1855 1886 1
499 532 7
277 354 ...

output:

-1

result:

ok single line: '-1'

Test #30:

score: 0
Accepted
time: 10ms
memory: 4256kb

input:

500 5 1994 203
1665 1672 5
1633 1634 2
1625 1628 4
1289 1290 2
153 166 2
915 936 2
1461 1485 2
1246 1248 5
611 651 3
309 334 4
1273 1281 4
1203 1240 2
1127 1174 5
1218 1245 5
1501 1532 3
1343 1348 5
1747 1772 4
952 969 3
717 718 4
1071 1084 3
1162 1178 4
467 472 1
386 406 5
1500 1524 1
322 329 5
142...

output:

0

result:

ok single line: '0'

Test #31:

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

input:

500 10 9995 663
8878 8936 7
1267 1493 10
5526 5563 10
4376 4457 9
1159 1870 4
8535 8748 8
5581 5900 10
1247 1645 5
589 1600 7
5047 5095 5
2914 3007 7
475 483 6
1910 2013 2
3447 3487 10
7316 7419 9
1021 1489 2
3240 3405 1
2385 2400 1
4690 4928 4
3237 3421 8
9801 9827 8
7064 7175 6
6689 7041 6
8307 84...

output:

4

result:

ok single line: '4'

Test #32:

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

input:

500 10 999999990 40283879
382252641 403037904 2
204393459 216047513 5
50504883 52495248 5
240464432 300782647 2
97211915 98443201 10
640912662 648459925 8
301391519 305516025 6
713477730 734255725 7
2262677 6077156 5
504494414 504703826 8
430473245 472571789 2
515199091 526286545 9
761851838 7626155...

output:

4

result:

ok single line: '4'

Test #33:

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

input:

500 10 999999990 70919885
141430607 143374564 2
714386880 735258724 1
742139018 779694899 8
261921042 263342912 2
361983558 392575287 3
511127832 524805278 5
439515570 455168331 9
699667477 705238262 5
701320733 735684736 9
733477232 749189798 5
776945538 806133244 2
579667169 582235732 10
683747275...

output:

5

result:

ok single line: '5'

Test #34:

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

input:

500 10 999997 85567
427687 455911 10
605236 608172 6
174081 183405 8
544961 555026 3
650190 666928 8
455912 501642 10
389139 397696 8
884203 887608 6
138459 151819 6
99579 126719 3
130540 131144 8
738829 778500 7
879258 889893 7
817049 837994 6
158957 160875 6
236246 247485 2
523200 544960 3
644705 ...

output:

-1

result:

ok single line: '-1'

Test #35:

score: 0
Accepted
time: 9ms
memory: 4028kb

input:

500 7 999999998 77849559
441617240 469416685 7
536231428 559395393 4
527548336 536231427 4
499598371 517933353 3
25211134 30393783 4
592054 25211133 4
188628295 204303674 3
129056986 138378194 3
861557064 912982049 3
156965722 158284385 6
382294619 387780376 5
210270941 218958577 3
666472754 6801102...

output:

3

result:

ok single line: '3'

Test #36:

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

input:

500 10 48934984 2260949
585715859 618347449 2
453099018 463205005 4
22463277 55691066 2
889537155 903565093 2
601181546 604853683 6
937371285 965885478 10
287031661 333249363 7
610027033 619073800 8
402995986 416878688 3
604853691 641865583 6
273112645 323438852 8
939672182 941961742 2
43081237 6050...

output:

-1

result:

ok single line: '-1'

Test #37:

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

input:

500 10 202747 12958
526655 554822 2
328920 349800 7
437855 441943 10
533577 584479 1
243680 251602 1
218847 246863 2
881985 918532 10
47192 78264 1
896630 906134 4
793946 799293 10
57897 97589 10
417308 437632 3
528119 535622 10
991217 1000000 5
1 7063 6
133725 137184 3
692941 719926 10
210976 23347...

output:

-1

result:

ok single line: '-1'

Test #38:

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

input:

500 7 338136779 6830400
118943861 124175401 3
435498285 464177099 3
735447936 735583390 1
694375488 721463137 1
155164620 192597504 2
505951776 507596568 1
340585509 343079764 2
186891228 189628546 3
677469382 700782215 4
966842362 967012271 5
275327667 302601132 6
90445986 92512068 1
459902747 5244...

output:

3

result:

ok single line: '3'

Test #39:

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

input:

500 10 1000000000 2
505681804 511363621 1
194029851 208955223 5
630769217 635897421 6
909090902 954545446 10
193181814 198863631 1
232954540 238636357 1
558974347 564102551 6
857954520 863636337 1
500000002 600000001 4
700000002 800000001 4
323076917 328205121 6
624999982 630681799 1
487179477 49230...

output:

5

result:

ok single line: '5'

Test #40:

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

input:

500 10 1000000000 1
442307666 451923049 6
74074070 80246908 7
487654283 493827121 7
691666641 699999973 5
933333298 941666630 5
518518478 524691316 7
249999992 258333324 5
913461482 923076865 6
599999978 608333310 5
941666631 949999963 5
179012333 185185171 7
907407335 913580173 7
574999979 58333331...

output:

6

result:

ok single line: '6'

Test #41:

score: 0
Accepted
time: 162ms
memory: 8272kb

input:

500 10 1000000000 1
1 2 1
11 12 1
21 22 1
31 32 1
41 42 1
51 52 1
61 62 1
71 72 1
81 82 1
91 92 1
101 102 1
111 112 1
121 122 1
131 132 1
141 142 1
151 152 1
161 162 1
171 172 1
181 182 1
191 192 1
201 202 1
211 212 1
221 222 1
231 232 1
241 242 1
251 252 1
261 262 1
271 272 1
281 282 1
291 292 1
30...

output:

0

result:

ok single line: '0'

Test #42:

score: 0
Accepted
time: 153ms
memory: 8756kb

input:

500 10 1000000000 1
1 2 1
11 12 1
21 22 1
31 32 1
41 42 1
51 52 1
61 62 1
71 72 1
81 82 1
91 92 1
101 102 1
111 112 1
121 122 1
131 132 1
141 142 1
151 152 1
161 162 1
171 172 1
181 182 1
191 192 1
201 202 1
211 212 1
221 222 1
231 232 1
241 242 1
251 252 1
261 262 1
271 272 1
281 282 1
291 292 1
30...

output:

0

result:

ok single line: '0'

Test #43:

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

input:

500 10 1000000000 1
1 2 1
11 12 1
21 22 1
31 32 1
41 42 1
51 52 1
61 62 1
71 72 1
81 82 1
91 92 1
101 102 1
111 112 1
121 122 1
131 132 1
141 142 1
151 152 1
161 162 1
171 172 1
181 182 1
191 192 1
201 202 1
211 212 1
221 222 1
231 232 1
241 242 1
251 252 1
261 262 1
271 272 1
281 282 1
291 292 1
30...

output:

0

result:

ok single line: '0'

Test #44:

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

input:

500 10 1000000000 1
90095455 90095456 1
90142508 90142509 1
90257390 90257391 1
90398914 90398915 1
90436412 90436413 1
90562406 90562407 1
90688363 90688364 1
90715162 90715163 1
90816244 90816245 1
90920985 90920986 1
91041330 91041331 1
91163578 91163579 1
91232616 91232617 1
91354374 91354375 1
...

output:

0

result:

ok single line: '0'

Test #45:

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

input:

10 5 18 2
1 5 1
6 18 1
3 9 2
10 18 2
5 10 3
11 18 3
7 14 4
15 18 4
9 15 5
16 18 5

output:

3

result:

ok single line: '3'

Test #46:

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

input:

500 10 1000000000 83333332
247874938 251105782 8
630157014 632962327 5
821317701 824576583 8
775194504 779761412 9
547686916 550430009 9
953359726 957250761 4
420362701 423349949 5
206978863 209245389 6
159383309 161387143 3
116458147 121015866 9
356262871 359086863 5
31647004 34842255 10
518525869 ...

output:

1

result:

ok single line: '1'

Test #47:

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

input:

500 10 1000000000 83333333
201576476 205603308 5
31984342 35201879 9
498366987 501161786 5
453961416 457064117 4
183000200 187110416 4
758181165 760785712 7
93746085 98312573 9
221372041 224624069 9
178338093 181176134 8
149211049 151387053 4
955715893 959818440 9
808671123 812488820 3
871675500 874...

output:

0

result:

ok single line: '0'

Test #48:

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

input:

500 10 1000000000 83333334
825302990 828972538 8
304475947 308169691 9
50494918 52439582 7
736383388 739822964 7
804429839 806945594 7
168249354 171530374 6
811027356 814613103 6
101334370 104612566 6
783845180 789369414 9
68251000 71476859 4
232124819 235790528 3
656502152 660228905 9
141693549 145...

output:

-1

result:

ok single line: '-1'

Test #49:

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

input:

500 10 1000000000 3
269958402 271835985 6
553206960 554777828 7
475693925 476821120 8
972101081 973646410 8
873956875 875033108 4
320231555 321267452 4
939637144 940944852 3
1 83333333 1
196718743 198409416 2
152875617 154517258 6
72992609 74385174 6
159101731 161248979 8
453377401 455127876 3
40504...

output:

2

result:

ok single line: '2'

Test #50:

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

input:

500 10 1000000000 1
262415263 263391474 2
570387072 572532286 3
586031782 586890642 8
40547 2070783 8
903023293 903893733 7
269230330 270711354 5
839086903 840792797 6
45278129 46960496 2
725269759 727290035 9
15575833 18150394 7
542698122 544332034 7
602615459 604300880 8
984189493 985237121 9
3713...

output:

1

result:

ok single line: '1'

Test #51:

score: 0
Accepted
time: 61ms
memory: 5304kb

input:

500 10 1000000000 30000000
250236470 250253607 4
430227440 430252822 7
129719462 129739259 2
129845196 129867662 2
370081802 370103689 6
130968682 130991814 2
489565334 489587613 8
550253389 550277946 9
190828236 190849537 3
490751507 490773660 8
490183955 490205512 8
129879718 129902172 2
190249878...

output:

2

result:

ok single line: '2'

Test #52:

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

input:

500 10 1000000000 30000000
550793205 550813494 9
489277387 489293365 8
550367736 550386016 9
129671639 129687485 2
430645993 430661301 7
369791695 369807521 6
369563976 369580102 6
370116020 370133887 6
189698782 189713386 3
490699199 490716929 8
250115180 250136861 4
491000001 1000000000 8
43084146...

output:

1

result:

ok single line: '1'

Test #53:

score: 0
Accepted
time: 154ms
memory: 10148kb

input:

500 10 1000000000 30000000
309953880 309957386 5
131000001 1000000000 2
310694728 310698170 5
549224157 549226475 9
129761913 129764099 2
309444554 309447474 5
429921664 429925753 7
489161299 489164536 8
370386738 370391430 6
189902327 189904978 3
189373308 189377680 3
430528052 430531671 7
24910364...

output:

1

result:

ok single line: '1'

Test #54:

score: 0
Accepted
time: 59ms
memory: 5200kb

input:

500 10 1000000000 30000000
1 70000000 1
309880428 309911369 5
189313957 189346406 3
130417691 130447481 2
249308644 249332885 4
550911137 550936414 9
310453985 310488443 5
370360315 370387999 6
309651772 309678131 5
250574302 250604253 4
550588887 550616540 9
129161386 129193138 2
130061249 13009024...

output:

1

result:

ok single line: '1'

Test #55:

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

input:

500 10 1000000000 30000000
370950318 370958051 6
370109367 370114580 6
130311941 130317712 2
490727708 490731585 8
490923472 490929024 8
369711850 369717019 6
249653516 249658987 4
370766017 370773563 6
129380300 129387381 2
250244565 250251064 4
489954480 489961831 8
129425289 129431918 2
250778999...

output:

2

result:

ok single line: '2'

Test #56:

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

input:

2 10 100 2
2 100 1
1 98 10

output:

2

result:

ok single line: '2'

Test #57:

score: 0
Accepted
time: 122ms
memory: 8320kb

input:

500 10 1000000000 30000000
309067993 309073367 5
69000325 69002554 1
250966722 250969329 4
310509332 310511690 5
250242129 250245039 4
309232208 309235162 5
429165835 429168915 7
369331406 369334323 6
609940343 609944542 10
430302433 430304915 7
369227966 369233841 6
429701024 429703931 7
489611856 ...

output:

1

result:

ok single line: '1'

Test #58:

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

input:

500 10 1000000000 30000000
489421081 489437457 8
370320202 370338817 6
609577749 609596733 10
490469606 490491220 8
610265515 610281976 10
130957749 130977342 2
489643779 489663846 8
610487927 610508079 10
130268106 130290655 2
370523890 370542718 6
130938944 130956141 2
250818805 250835254 4
370712...

output:

4

result:

ok single line: '4'

Test #59:

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

input:

2 10 200 3
1 90 1
50 200 5

output:

-1

result:

ok single line: '-1'

Test #60:

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

input:

2 10 100 2
10 100 1
1 90 10

output:

0

result:

ok single line: '0'

Test #61:

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

input:

10 3 100 6
82 87 1
11 22 1
44 51 2
28 29 1
52 95 3
33 39 3
1 10 2
68 75 2
68 74 1
13 19 2

output:

0

result:

ok single line: '0'