QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#217564#4363. Branch AssignmentwaifuSenpai#AC ✓195ms198236kbC++202.2kb2023-10-16 23:51:282023-10-16 23:51:28

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3824kb

input:

5 4 2 10
5 2 1
2 5 1
3 5 5
4 5 0
1 5 1
2 3 1
3 2 5
2 4 5
2 1 1
3 4 2

output:

13

result:

ok single line: '13'

Test #2:

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

input:

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

output:

24

result:

ok single line: '24'

Test #3:

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

input:

5 4 3 8
1 5 15
5 1 15
2 5 2
5 2 3
3 5 1
5 3 1
4 5 2
5 4 0

output:

4

result:

ok single line: '4'

Test #4:

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

input:

2 1 1 2
1 2 5
2 1 3

output:

0

result:

ok single line: '0'

Test #5:

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

input:

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

output:

304

result:

ok single line: '304'

Test #6:

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

input:

5000 4999 2 9998
1 2 10000
2 1 10000
2 3 10000
3 2 10000
3 4 10000
4 3 10000
4 5 10000
5 4 10000
5 6 10000
6 5 10000
6 7 10000
7 6 10000
7 8 10000
8 7 10000
8 9 10000
9 8 10000
9 10 10000
10 9 10000
10 11 10000
11 10 10000
11 12 10000
12 11 10000
12 13 10000
13 12 10000
13 14 10000
14 13 10000
14 15...

output:

589335814500000

result:

ok single line: '589335814500000'

Test #7:

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

input:

5000 4999 100 9998
1 2 1
2 3 1
3 4 1
4 5 1
5 6 1
6 7 1
7 8 1
8 9 1
9 10 1
10 11 1
11 12 1
12 13 1
13 14 1
14 15 1
15 16 1
16 17 1
17 18 1
18 19 1
19 20 1
20 21 1
21 22 1
22 23 1
23 24 1
24 25 1
25 26 1
26 27 1
27 28 1
28 29 1
29 30 1
30 31 1
31 32 1
32 33 1
33 34 1
34 35 1
35 36 1
36 37 1
37 38 1
38...

output:

1224510000

result:

ok single line: '1224510000'

Test #8:

score: 0
Accepted
time: 131ms
memory: 85520kb

input:

5000 4900 2000 50000
3116 1995 5417
1801 380 719
4749 13 4103
1175 493 659
596 3035 2098
628 2199 2816
711 3295 5220
4888 4316 153
1007 2136 1990
1365 1579 8062
4076 1263 7023
3114 3756 2785
3695 3175 3364
2302 3474 5739
3062 3705 9620
3815 1026 7712
3991 3582 3049
3245 2397 5834
18 1456 1619
2186 4...

output:

166040058

result:

ok single line: '166040058'

Test #9:

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

input:

5000 4950 2 50000
3669 4840 0
614 3306 0
290 1311 0
2359 2891 0
3497 3550 0
3428 2623 0
1940 3386 0
3650 1263 0
2260 4950 0
1588 3186 0
4498 1773 0
4295 296 0
2956 1009 0
176 3322 0
4509 2130 0
894 4934 0
281 1204 0
1731 14 0
2405 1590 0
1315 635 0
1469 195 0
3651 647 0
82 4604 0
1171 195 0
4275 401...

output:

0

result:

ok single line: '0'

Test #10:

score: 0
Accepted
time: 195ms
memory: 197252kb

input:

5000 4900 4850 50000
2664 4071 4296
612 1817 6511
2292 3113 8392
961 4255 1637
4959 1976 2034
1664 4624 1380
912 3972 8714
1207 2958 2443
3503 729 2610
4920 3996 8547
63 1698 7911
948 4574 1568
1045 4886 5174
3103 4846 1519
875 3369 6492
632 2688 563
1632 3563 588
3929 1553 6982
4707 1623 1425
2762 ...

output:

1182041

result:

ok single line: '1182041'

Test #11:

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

input:

5000 4950 2 50000
1218 2222 2897
2887 2737 8305
229 2321 4170
4168 3818 9202
1790 221 4606
2545 1061 7338
1169 592 2259
4092 4087 2360
3322 1047 6485
2970 328 6695
494 4516 2381
3342 4606 4670
3612 3942 9868
834 1386 6434
1142 1782 9753
1709 1989 9597
1149 20 7387
4936 4604 4163
3505 1877 594
4564 2...

output:

254153797367

result:

ok single line: '254153797367'

Test #12:

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

input:

5000 4999 70 50000
1060 1927 0
305 2800 4
2718 2374 9
3134 2200 2
962 1174 7
3953 4904 10
534 4874 10
812 4718 10
4015 728 0
1142 1263 2
864 4957 2
2368 2520 0
814 843 0
1628 3903 8
2067 1860 6
3054 449 6
1611 993 1
4114 4522 3
4264 1745 2
2946 3536 6
901 1625 3
1861 3452 10
1953 179 1
1112 271 3
13...

output:

2767588

result:

ok single line: '2767588'

Test #13:

score: 0
Accepted
time: 183ms
memory: 198236kb

input:

5000 4950 4900 50000
1683 1801 0
3511 3698 0
2360 4358 0
75 2274 0
1670 2492 0
3576 4624 0
1833 34 0
3759 4205 0
2081 242 0
3120 235 0
3924 4140 0
3067 3547 0
3793 644 0
4333 1287 0
2083 4043 0
2643 3799 0
4311 4466 0
4919 1 0
1458 3787 0
1870 345 0
3481 1274 0
3095 1988 0
742 4480 0
4047 3163 0
164...

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 155ms
memory: 122360kb

input:

5000 4999 3000 9998
1 5000 1
5000 1 1
2 5000 1
5000 2 1
3 5000 1
5000 3 1
4 5000 1
5000 4 1
5 5000 1
5000 5 1
6 5000 1
5000 6 1
7 5000 1
5000 7 1
8 5000 1
5000 8 1
9 5000 1
5000 9 1
10 5000 1
5000 10 1
11 5000 1
5000 11 1
12 5000 1
5000 12 1
13 5000 1
5000 13 1
14 5000 1
5000 14 1
15 5000 1
5000 15 ...

output:

7996

result:

ok single line: '7996'

Test #15:

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

input:

38 37 5 74
1 38 1
38 1 0
2 38 1
38 2 0
3 38 1
38 3 0
4 38 1
38 4 0
5 38 1
38 5 0
6 38 1
38 6 0
7 38 1
38 7 0
8 38 1
38 8 0
9 38 1
38 9 0
10 38 1
38 10 0
11 38 1
38 11 0
12 38 1
38 12 0
13 38 1
38 13 0
14 38 1
38 14 0
15 38 1
38 15 0
16 38 1
38 16 0
17 38 1
38 17 0
18 38 1
38 18 0
19 38 1
38 19 0
20 ...

output:

544

result:

ok single line: '544'

Test #16:

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

input:

65 64 5 128
1 65 1
65 1 0
2 65 1
65 2 0
3 65 1
65 3 0
4 65 1
65 4 0
5 65 1
65 5 0
6 65 1
65 6 0
7 65 1
65 7 0
8 65 1
65 8 0
9 65 1
65 9 0
10 65 1
65 10 0
11 65 1
65 11 0
12 65 1
65 12 0
13 65 1
65 13 0
14 65 1
65 14 0
15 65 1
65 15 0
16 65 1
65 16 0
17 65 1
65 17 0
18 65 1
65 18 0
19 65 1
65 19 0
20...

output:

2940

result:

ok single line: '2940'

Test #17:

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

input:

3919 3918 174 7836
1 3919 1
3919 1 0
2 3919 1
3919 2 0
3 3919 1
3919 3 0
4 3919 1
3919 4 0
5 3919 1
3919 5 0
6 3919 1
3919 6 0
7 3919 1
3919 7 0
8 3919 1
3919 8 0
9 3919 1
3919 9 0
10 3919 1
3919 10 0
11 3919 1
3919 11 0
12 3919 1
3919 12 0
13 3919 1
3919 13 0
14 3919 1
3919 14 0
15 3919 1
3919 15 0...

output:

261936

result:

ok single line: '261936'

Test #18:

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

input:

3209 3208 164 6416
1 3209 1
3209 1 0
2 3209 1
3209 2 0
3 3209 1
3209 3 0
4 3209 1
3209 4 0
5 3209 1
3209 5 0
6 3209 1
3209 6 0
7 3209 1
3209 7 0
8 3209 1
3209 8 0
9 3209 1
3209 9 0
10 3209 1
3209 10 0
11 3209 1
3209 11 0
12 3209 1
3209 12 0
13 3209 1
3209 13 0
14 3209 1
3209 14 0
15 3209 1
3209 15 0...

output:

142260

result:

ok single line: '142260'

Test #19:

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

input:

2352 2351 454 4702
1 2352 1
2352 1 0
2 2352 1
2352 2 0
3 2352 1
2352 3 0
4 2352 1
2352 4 0
5 2352 1
2352 5 0
6 2352 1
2352 6 0
7 2352 1
2352 7 0
8 2352 1
2352 8 0
9 2352 1
2352 9 0
10 2352 1
2352 10 0
11 2352 1
2352 11 0
12 2352 1
2352 12 0
13 2352 1
2352 13 0
14 2352 1
2352 14 0
15 2352 1
2352 15 0...

output:

87296

result:

ok single line: '87296'

Test #20:

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

input:

2298 2297 115 4594
1 2298 1
2298 1 0
2 2298 1
2298 2 0
3 2298 1
2298 3 0
4 2298 1
2298 4 0
5 2298 1
2298 5 0
6 2298 1
2298 6 0
7 2298 1
2298 7 0
8 2298 1
2298 8 0
9 2298 1
2298 9 0
10 2298 1
2298 10 0
11 2298 1
2298 11 0
12 2298 1
2298 12 0
13 2298 1
2298 13 0
14 2298 1
2298 14 0
15 2298 1
2298 15 0...

output:

235810

result:

ok single line: '235810'

Test #21:

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

input:

621 620 6 1240
1 621 1
621 1 0
2 621 1
621 2 0
3 621 1
621 3 0
4 621 1
621 4 0
5 621 1
621 5 0
6 621 1
621 6 0
7 621 1
621 7 0
8 621 1
621 8 0
9 621 1
621 9 0
10 621 1
621 10 0
11 621 1
621 11 0
12 621 1
621 12 0
13 621 1
621 13 0
14 621 1
621 14 0
15 621 1
621 15 0
16 621 1
621 16 0
17 621 1
621 17...

output:

360530

result:

ok single line: '360530'

Test #22:

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

input:

1392 1391 65 2782
1 1392 1
1392 1 0
2 1392 1
1392 2 0
3 1392 1
1392 3 0
4 1392 1
1392 4 0
5 1392 1
1392 5 0
6 1392 1
1392 6 0
7 1392 1
1392 7 0
8 1392 1
1392 8 0
9 1392 1
1392 9 0
10 1392 1
1392 10 0
11 1392 1
1392 11 0
12 1392 1
1392 12 0
13 1392 1
1392 13 0
14 1392 1
1392 14 0
15 1392 1
1392 15 0
...

output:

34528

result:

ok single line: '34528'

Test #23:

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

input:

2940 2939 86 5878
1 2940 1
2940 1 0
2 2940 1
2940 2 0
3 2940 1
2940 3 0
4 2940 1
2940 4 0
5 2940 1
2940 5 0
6 2940 1
2940 6 0
7 2940 1
2940 7 0
8 2940 1
2940 8 0
9 2940 1
2940 9 0
10 2940 1
2940 10 0
11 2940 1
2940 11 0
12 2940 1
2940 12 0
13 2940 1
2940 13 0
14 2940 1
2940 14 0
15 2940 1
2940 15 0
...

output:

209202

result:

ok single line: '209202'

Test #24:

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

input:

3839 3838 55 7676
1 3839 1
3839 1 0
2 3839 1
3839 2 0
3 3839 1
3839 3 0
4 3839 1
3839 4 0
5 3839 1
3839 5 0
6 3839 1
3839 6 0
7 3839 1
3839 7 0
8 3839 1
3839 8 0
9 3839 1
3839 9 0
10 3839 1
3839 10 0
11 3839 1
3839 11 0
12 3839 1
3839 12 0
13 3839 1
3839 13 0
14 3839 1
3839 14 0
15 3839 1
3839 15 0
...

output:

435042

result:

ok single line: '435042'

Test #25:

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

input:

628 627 21 1254
1 628 1
628 1 0
2 628 1
628 2 0
3 628 1
628 3 0
4 628 1
628 4 0
5 628 1
628 5 0
6 628 1
628 6 0
7 628 1
628 7 0
8 628 1
628 8 0
9 628 1
628 9 0
10 628 1
628 10 0
11 628 1
628 11 0
12 628 1
628 12 0
13 628 1
628 13 0
14 628 1
628 14 0
15 628 1
628 15 0
16 628 1
628 16 0
17 628 1
628 1...

output:

119938

result:

ok single line: '119938'

Test #26:

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

input:

1137 1136 15 2272
1 1137 1
1137 1 0
2 1137 1
1137 2 0
3 1137 1
1137 3 0
4 1137 1
1137 4 0
5 1137 1
1137 5 0
6 1137 1
1137 6 0
7 1137 1
1137 7 0
8 1137 1
1137 8 0
9 1137 1
1137 9 0
10 1137 1
1137 10 0
11 1137 1
1137 11 0
12 1137 1
1137 12 0
13 1137 1
1137 13 0
14 1137 1
1137 14 0
15 1137 1
1137 15 0
...

output:

408268

result:

ok single line: '408268'

Test #27:

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

input:

908 907 26 1814
1 908 1
908 1 0
2 908 1
908 2 0
3 908 1
908 3 0
4 908 1
908 4 0
5 908 1
908 5 0
6 908 1
908 6 0
7 908 1
908 7 0
8 908 1
908 8 0
9 908 1
908 9 0
10 908 1
908 10 0
11 908 1
908 11 0
12 908 1
908 12 0
13 908 1
908 13 0
14 908 1
908 14 0
15 908 1
908 15 0
16 908 1
908 16 0
17 908 1
908 1...

output:

47100

result:

ok single line: '47100'

Test #28:

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

input:

4421 4420 343 8840
1 4421 1
4421 1 0
2 4421 1
4421 2 0
3 4421 1
4421 3 0
4 4421 1
4421 4 0
5 4421 1
4421 5 0
6 4421 1
4421 6 0
7 4421 1
4421 7 0
8 4421 1
4421 8 0
9 4421 1
4421 9 0
10 4421 1
4421 10 0
11 4421 1
4421 11 0
12 4421 1
4421 12 0
13 4421 1
4421 13 0
14 4421 1
4421 14 0
15 4421 1
4421 15 0...

output:

71580

result:

ok single line: '71580'

Test #29:

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

input:

2835 2834 443 5668
1 2835 1
2835 1 0
2 2835 1
2835 2 0
3 2835 1
2835 3 0
4 2835 1
2835 4 0
5 2835 1
2835 5 0
6 2835 1
2835 6 0
7 2835 1
2835 7 0
8 2835 1
2835 8 0
9 2835 1
2835 9 0
10 2835 1
2835 10 0
11 2835 1
2835 11 0
12 2835 1
2835 12 0
13 2835 1
2835 13 0
14 2835 1
2835 14 0
15 2835 1
2835 15 0...

output:

68772

result:

ok single line: '68772'

Test #30:

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

input:

1648 1647 46 3294
1 1648 1
1648 1 0
2 1648 1
1648 2 0
3 1648 1
1648 3 0
4 1648 1
1648 4 0
5 1648 1
1648 5 0
6 1648 1
1648 6 0
7 1648 1
1648 7 0
8 1648 1
1648 8 0
9 1648 1
1648 9 0
10 1648 1
1648 10 0
11 1648 1
1648 11 0
12 1648 1
1648 12 0
13 1648 1
1648 13 0
14 1648 1
1648 14 0
15 1648 1
1648 15 0
...

output:

179754

result:

ok single line: '179754'

Test #31:

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

input:

4331 4330 202 8660
1 4331 1
4331 1 0
2 4331 1
4331 2 0
3 4331 1
4331 3 0
4 4331 1
4331 4 0
5 4331 1
4331 5 0
6 4331 1
4331 6 0
7 4331 1
4331 7 0
8 4331 1
4331 8 0
9 4331 1
4331 9 0
10 4331 1
4331 10 0
11 4331 1
4331 11 0
12 4331 1
4331 12 0
13 4331 1
4331 13 0
14 4331 1
4331 14 0
15 4331 1
4331 15 0...

output:

235280

result:

ok single line: '235280'

Test #32:

score: 0
Accepted
time: 5ms
memory: 8240kb

input:

1867 1866 83 3732
1 1867 1
1867 1 0
2 1867 1
1867 2 0
3 1867 1
1867 3 0
4 1867 1
1867 4 0
5 1867 1
1867 5 0
6 1867 1
1867 6 0
7 1867 1
1867 7 0
8 1867 1
1867 8 0
9 1867 1
1867 9 0
10 1867 1
1867 10 0
11 1867 1
1867 11 0
12 1867 1
1867 12 0
13 1867 1
1867 13 0
14 1867 1
1867 14 0
15 1867 1
1867 15 0
...

output:

211952

result:

ok single line: '211952'

Test #33:

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

input:

4769 4768 9 9536
1 4769 1
4769 1 0
2 4769 1
4769 2 0
3 4769 1
4769 3 0
4 4769 1
4769 4 0
5 4769 1
4769 5 0
6 4769 1
4769 6 0
7 4769 1
4769 7 0
8 4769 1
4769 8 0
9 4769 1
4769 9 0
10 4769 1
4769 10 0
11 4769 1
4769 11 0
12 4769 1
4769 12 0
13 4769 1
4769 13 0
14 4769 1
4769 14 0
15 4769 1
4769 15 0
1...

output:

5152484

result:

ok single line: '5152484'

Test #34:

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

input:

3447 3446 174 6892
1 3447 1
3447 1 0
2 3447 1
3447 2 0
3 3447 1
3447 3 0
4 3447 1
3447 4 0
5 3447 1
3447 5 0
6 3447 1
3447 6 0
7 3447 1
3447 7 0
8 3447 1
3447 8 0
9 3447 1
3447 9 0
10 3447 1
3447 10 0
11 3447 1
3447 11 0
12 3447 1
3447 12 0
13 3447 1
3447 13 0
14 3447 1
3447 14 0
15 3447 1
3447 15 0...

output:

169856

result:

ok single line: '169856'

Test #35:

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

input:

3405 3404 452 6808
1 3405 1
3405 1 0
2 3405 1
3405 2 0
3 3405 1
3405 3 0
4 3405 1
3405 4 0
5 3405 1
3405 5 0
6 3405 1
3405 6 0
7 3405 1
3405 7 0
8 3405 1
3405 8 0
9 3405 1
3405 9 0
10 3405 1
3405 10 0
11 3405 1
3405 11 0
12 3405 1
3405 12 0
13 3405 1
3405 13 0
14 3405 1
3405 14 0
15 3405 1
3405 15 0...

output:

77658

result:

ok single line: '77658'

Test #36:

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

input:

1445 1444 114 2888
1 1445 1
1445 1 0
2 1445 1
1445 2 0
3 1445 1
1445 3 0
4 1445 1
1445 4 0
5 1445 1
1445 5 0
6 1445 1
1445 6 0
7 1445 1
1445 7 0
8 1445 1
1445 8 0
9 1445 1
1445 9 0
10 1445 1
1445 10 0
11 1445 1
1445 11 0
12 1445 1
1445 12 0
13 1445 1
1445 13 0
14 1445 1
1445 14 0
15 1445 1
1445 15 0...

output:

122256

result:

ok single line: '122256'

Test #37:

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

input:

1795 1794 49 3588
1 1795 1
1795 1 0
2 1795 1
1795 2 0
3 1795 1
1795 3 0
4 1795 1
1795 4 0
5 1795 1
1795 5 0
6 1795 1
1795 6 0
7 1795 1
1795 7 0
8 1795 1
1795 8 0
9 1795 1
1795 9 0
10 1795 1
1795 10 0
11 1795 1
1795 11 0
12 1795 1
1795 12 0
13 1795 1
1795 13 0
14 1795 1
1795 14 0
15 1795 1
1795 15 0
...

output:

281246

result:

ok single line: '281246'

Test #38:

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

input:

4559 4558 328 9116
1 4559 1
4559 1 0
2 4559 1
4559 2 0
3 4559 1
4559 3 0
4 4559 1
4559 4 0
5 4559 1
4559 5 0
6 4559 1
4559 6 0
7 4559 1
4559 7 0
8 4559 1
4559 8 0
9 4559 1
4559 9 0
10 4559 1
4559 10 0
11 4559 1
4559 11 0
12 4559 1
4559 12 0
13 4559 1
4559 13 0
14 4559 1
4559 14 0
15 4559 1
4559 15 0...

output:

148688

result:

ok single line: '148688'

Test #39:

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

input:

1499 1498 123 2996
1 1499 1
1499 1 0
2 1499 1
1499 2 0
3 1499 1
1499 3 0
4 1499 1
1499 4 0
5 1499 1
1499 5 0
6 1499 1
1499 6 0
7 1499 1
1499 7 0
8 1499 1
1499 8 0
9 1499 1
1499 9 0
10 1499 1
1499 10 0
11 1499 1
1499 11 0
12 1499 1
1499 12 0
13 1499 1
1499 13 0
14 1499 1
1499 14 0
15 1499 1
1499 15 0...

output:

84246

result:

ok single line: '84246'

Test #40:

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

input:

999 998 64 1996
1 999 1
999 1 0
2 999 1
999 2 0
3 999 1
999 3 0
4 999 1
999 4 0
5 999 1
999 5 0
6 999 1
999 6 0
7 999 1
999 7 0
8 999 1
999 8 0
9 999 1
999 9 0
10 999 1
999 10 0
11 999 1
999 11 0
12 999 1
999 12 0
13 999 1
999 13 0
14 999 1
999 14 0
15 999 1
999 15 0
16 999 1
999 16 0
17 999 1
999 1...

output:

59454

result:

ok single line: '59454'

Test #41:

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

input:

3820 3819 108 7638
1 3820 1
3820 1 0
2 3820 1
3820 2 0
3 3820 1
3820 3 0
4 3820 1
3820 4 0
5 3820 1
3820 5 0
6 3820 1
3820 6 0
7 3820 1
3820 7 0
8 3820 1
3820 8 0
9 3820 1
3820 9 0
10 3820 1
3820 10 0
11 3820 1
3820 11 0
12 3820 1
3820 12 0
13 3820 1
3820 13 0
14 3820 1
3820 14 0
15 3820 1
3820 15 0...

output:

636706

result:

ok single line: '636706'

Test #42:

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

input:

4058 4057 247 8114
1 4058 1
4058 1 0
2 4058 1
4058 2 0
3 4058 1
4058 3 0
4 4058 1
4058 4 0
5 4058 1
4058 5 0
6 4058 1
4058 6 0
7 4058 1
4058 7 0
8 4058 1
4058 8 0
9 4058 1
4058 9 0
10 4058 1
4058 10 0
11 4058 1
4058 11 0
12 4058 1
4058 12 0
13 4058 1
4058 13 0
14 4058 1
4058 14 0
15 4058 1
4058 15 0...

output:

165984

result:

ok single line: '165984'

Test #43:

score: 0
Accepted
time: 118ms
memory: 74716kb

input:

4931 4930 1747 9860
1 4931 1
4931 1 0
2 4931 1
4931 2 0
3 4931 1
4931 3 0
4 4931 1
4931 4 0
5 4931 1
4931 5 0
6 4931 1
4931 6 0
7 4931 1
4931 7 0
8 4931 1
4931 8 0
9 4931 1
4931 9 0
10 4931 1
4931 10 0
11 4931 1
4931 11 0
12 4931 1
4931 12 0
13 4931 1
4931 13 0
14 4931 1
4931 14 0
15 4931 1
4931 15 ...

output:

13962

result:

ok single line: '13962'

Test #44:

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

input:

1865 1864 1381 3728
1 1865 1
1865 1 0
2 1865 1
1865 2 0
3 1865 1
1865 3 0
4 1865 1
1865 4 0
5 1865 1
1865 5 0
6 1865 1
1865 6 0
7 1865 1
1865 7 0
8 1865 1
1865 8 0
9 1865 1
1865 9 0
10 1865 1
1865 10 0
11 1865 1
1865 11 0
12 1865 1
1865 12 0
13 1865 1
1865 13 0
14 1865 1
1865 14 0
15 1865 1
1865 15 ...

output:

966

result:

ok single line: '966'

Test #45:

score: 0
Accepted
time: 135ms
memory: 145816kb

input:

4385 4384 3571 8768
1 4385 1
4385 1 0
2 4385 1
4385 2 0
3 4385 1
4385 3 0
4 4385 1
4385 4 0
5 4385 1
4385 5 0
6 4385 1
4385 6 0
7 4385 1
4385 7 0
8 4385 1
4385 8 0
9 4385 1
4385 9 0
10 4385 1
4385 10 0
11 4385 1
4385 11 0
12 4385 1
4385 12 0
13 4385 1
4385 13 0
14 4385 1
4385 14 0
15 4385 1
4385 15 ...

output:

1626

result:

ok single line: '1626'

Test #46:

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

input:

1768 1767 54 3534
1 1768 1
1768 1 0
2 1768 1
1768 2 0
3 1768 1
1768 3 0
4 1768 1
1768 4 0
5 1768 1
1768 5 0
6 1768 1
1768 6 0
7 1768 1
1768 7 0
8 1768 1
1768 8 0
9 1768 1
1768 9 0
10 1768 1
1768 10 0
11 1768 1
1768 11 0
12 1768 1
1768 12 0
13 1768 1
1768 13 0
14 1768 1
1768 14 0
15 1768 1
1768 15 0
...

output:

57938

result:

ok single line: '57938'

Test #47:

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

input:

479 478 456 956
1 479 1
479 1 0
2 479 1
479 2 0
3 479 1
479 3 0
4 479 1
479 4 0
5 479 1
479 5 0
6 479 1
479 6 0
7 479 1
479 7 0
8 479 1
479 8 0
9 479 1
479 9 0
10 479 1
479 10 0
11 479 1
479 11 0
12 479 1
479 12 0
13 479 1
479 13 0
14 479 1
479 14 0
15 479 1
479 15 0
16 479 1
479 16 0
17 479 1
479 1...

output:

44

result:

ok single line: '44'

Test #48:

score: 0
Accepted
time: 4ms
memory: 24696kb

input:

765 764 519 1528
1 765 1
765 1 0
2 765 1
765 2 0
3 765 1
765 3 0
4 765 1
765 4 0
5 765 1
765 5 0
6 765 1
765 6 0
7 765 1
765 7 0
8 765 1
765 8 0
9 765 1
765 9 0
10 765 1
765 10 0
11 765 1
765 11 0
12 765 1
765 12 0
13 765 1
765 13 0
14 765 1
765 14 0
15 765 1
765 15 0
16 765 1
765 16 0
17 765 1
765 ...

output:

490

result:

ok single line: '490'

Test #49:

score: 0
Accepted
time: 74ms
memory: 113348kb

input:

3193 3192 2763 6384
1 3193 1
3193 1 0
2 3193 1
3193 2 0
3 3193 1
3193 3 0
4 3193 1
3193 4 0
5 3193 1
3193 5 0
6 3193 1
3193 6 0
7 3193 1
3193 7 0
8 3193 1
3193 8 0
9 3193 1
3193 9 0
10 3193 1
3193 10 0
11 3193 1
3193 11 0
12 3193 1
3193 12 0
13 3193 1
3193 13 0
14 3193 1
3193 14 0
15 3193 1
3193 15 ...

output:

858

result:

ok single line: '858'

Test #50:

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

input:

785 784 117 1568
1 785 1
785 1 0
2 785 1
785 2 0
3 785 1
785 3 0
4 785 1
785 4 0
5 785 1
785 5 0
6 785 1
785 6 0
7 785 1
785 7 0
8 785 1
785 8 0
9 785 1
785 9 0
10 785 1
785 10 0
11 785 1
785 11 0
12 785 1
785 12 0
13 785 1
785 13 0
14 785 1
785 14 0
15 785 1
785 15 0
16 785 1
785 16 0
17 785 1
785 ...

output:

29330

result:

ok single line: '29330'

Test #51:

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

input:

3501 3500 1746 7000
1 3501 1
3501 1 0
2 3501 1
3501 2 0
3 3501 1
3501 3 0
4 3501 1
3501 4 0
5 3501 1
3501 5 0
6 3501 1
3501 6 0
7 3501 1
3501 7 0
8 3501 1
3501 8 0
9 3501 1
3501 9 0
10 3501 1
3501 10 0
11 3501 1
3501 11 0
12 3501 1
3501 12 0
13 3501 1
3501 13 0
14 3501 1
3501 14 0
15 3501 1
3501 15 ...

output:

5376

result:

ok single line: '5376'

Test #52:

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

input:

99 98 97 196
1 99 1
99 1 0
2 99 1
99 2 0
3 99 1
99 3 0
4 99 1
99 4 0
5 99 1
99 5 0
6 99 1
99 6 0
7 99 1
99 7 0
8 99 1
99 8 0
9 99 1
99 9 0
10 99 1
99 10 0
11 99 1
99 11 0
12 99 1
99 12 0
13 99 1
99 13 0
14 99 1
99 14 0
15 99 1
99 15 0
16 99 1
99 16 0
17 99 1
99 17 0
18 99 1
99 18 0
19 99 1
99 19 0
2...

output:

2

result:

ok single line: '2'