QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#474498#2714. Mountains and ValleysMilmon25 ✓2971ms322960kbC++143.1kb2024-07-12 19:19:082024-07-12 19:19:09

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 13ms
memory: 68320kb

input:

4 3
0 1 1
0 2 1
0 3 1

output:

4

result:

ok single line: '4'

Test #2:

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

input:

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

output:

5

result:

ok single line: '5'

Test #3:

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

input:

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

output:

5

result:

ok single line: '5'

Test #4:

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

input:

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

output:

6

result:

ok single line: '6'

Test #5:

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

input:

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

output:

7

result:

ok single line: '7'

Test #6:

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

input:

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

output:

8

result:

ok single line: '8'

Test #7:

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

input:

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

output:

8

result:

ok single line: '8'

Test #8:

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

input:

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

output:

5

result:

ok single line: '5'

Test #9:

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

input:

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

output:

5

result:

ok single line: '5'

Test #10:

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

input:

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

output:

5

result:

ok single line: '5'

Test #11:

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

input:

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

output:

6

result:

ok single line: '6'

Test #12:

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

input:

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

output:

6

result:

ok single line: '6'

Test #13:

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

input:

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

output:

6

result:

ok single line: '6'

Test #14:

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

input:

6 6
1 5 1
5 0 1
3 1 2
3 2 1
4 2 1
2 5 1

output:

6

result:

ok single line: '6'

Test #15:

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

input:

6 6
1 4 2
2 3 1
4 2 1
5 0 1
1 0 1
0 2 1

output:

6

result:

ok single line: '6'

Subtask #2:

score: 2
Accepted

Test #16:

score: 2
Accepted
time: 8ms
memory: 69940kb

input:

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

output:

11

result:

ok single line: '11'

Test #17:

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

input:

9 9
0 1 1
1 2 1
2 3 1
3 4 1
2 5 1
5 6 1
2 7 1
7 8 1
4 6 3

output:

11

result:

ok single line: '11'

Test #18:

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

input:

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

output:

15

result:

ok single line: '15'

Test #19:

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

input:

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

output:

20

result:

ok single line: '20'

Test #20:

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

input:

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

output:

20

result:

ok single line: '20'

Test #21:

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

input:

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

output:

19

result:

ok single line: '19'

Test #22:

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

input:

19 40
2 12 1
12 1 8
6 15 9
4 7 1
4 0 8
3 7 13
15 11 1
11 18 1
3 12 7
9 13 1
17 16 1
6 12 9
7 1 8
3 1 1
2 9 7
8 10 1
0 12 9
16 5 1
15 0 9
2 4 1
0 1 1
17 13 1
2 3 11
2 10 8
9 8 1
10 6 1
2 6 7
4 6 10
1 11 7
15 12 1
14 18 1
1 18 7
8 15 7
15 1 8
5 14 1
6 0 1
7 10 12
2 8 9
4 3 12
1 2 10

output:

18

result:

ok single line: '18'

Test #23:

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

input:

19 40
2 10 1
17 4 1
12 13 7
5 14 1
8 10 1
0 6 1
13 9 7
12 14 7
15 3 1
1 2 8
7 8 1
12 1 8
16 9 7
18 13 8
1 16 1
2 13 1
10 9 7
12 8 7
18 2 7
9 1 7
9 18 7
13 1 9
0 9 1
16 2 7
12 16 8
17 6 1
16 10 7
14 18 1
18 0 7
9 2 8
18 16 1
11 5 1
14 9 7
4 15 1
2 0 8
15 11 1
12 9 1
12 2 9
3 7 1
10 12 7

output:

24

result:

ok single line: '24'

Test #24:

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

input:

18 40
0 7 1
16 10 1
11 5 6
17 16 1
13 3 6
9 10 1
6 12 1
6 3 6
15 13 1
2 12 1
4 3 1
8 11 1
5 3 6
8 15 6
6 11 6
11 3 6
13 8 6
2 14 1
0 16 1
17 1 1
13 4 6
7 15 1
3 8 6
9 5 6
13 5 6
1 11 1
4 5 7
1 5 6
12 8 6
12 13 6
5 8 7
11 13 6
15 3 6
4 9 1
15 5 7
12 3 6
6 5 1
16 14 1
15 6 6
4 8 6

output:

23

result:

ok single line: '23'

Test #25:

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

input:

18 40
17 0 12
3 12 13
14 12 6
13 16 1
6 0 10
4 8 6
11 16 1
7 4 14
5 16 1
16 2 1
10 12 15
6 1 12
0 9 1
14 6 9
7 12 6
15 10 1
12 4 1
17 4 1
3 8 11
12 8 6
13 9 1
0 8 6
17 14 13
14 3 1
9 6 8
2 10 9
12 1 6
13 12 14
0 12 6
7 6 1
8 14 6
8 1 6
17 8 12
8 7 1
6 11 1
5 17 1
1 10 1
4 13 8
2 3 1
15 16 1

output:

26

result:

ok single line: '26'

Test #26:

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

input:

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

output:

36

result:

ok single line: '36'

Test #27:

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

input:

18 40
1 7 10
5 12 1
16 4 1
5 1 6
12 14 1
6 12 1
10 5 10
1 17 7
0 8 1
10 14 7
17 15 1
12 2 6
1 10 1
1 6 6
7 10 6
2 1 1
11 14 6
11 17 6
6 11 6
14 1 10
9 3 1
2 7 9
6 2 6
5 7 1
2 5 6
11 12 6
5 11 7
15 4 1
2 11 1
6 17 1
14 2 7
1 12 6
2 9 1
12 10 7
3 13 1
10 0 1
13 16 1
10 17 7
17 2 6
11 7 10

output:

19

result:

ok single line: '19'

Test #28:

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

input:

18 40
10 15 6
15 6 6
16 10 6
4 16 6
17 7 1
12 6 6
0 11 1
8 9 1
1 4 6
1 9 1
6 16 1
15 9 6
10 17 6
5 10 6
1 16 6
7 11 1
15 5 7
3 2 1
10 6 6
1 17 6
3 6 1
14 4 1
4 15 1
12 16 6
10 2 7
2 7 1
1 12 6
15 12 1
8 13 1
14 11 1
15 1 6
12 10 8
0 13 1
12 5 6
1 10 1
6 5 1
6 9 6
16 15 6
7 10 6
6 1 7

output:

23

result:

ok single line: '23'

Test #29:

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

input:

18 40
7 12 1
14 0 1
10 14 6
4 13 1
5 8 6
15 2 1
5 17 1
0 9 6
13 10 6
16 2 1
13 8 7
9 1 11
0 3 7
6 9 1
4 12 1
17 11 1
13 1 9
8 3 1
6 14 6
0 10 6
9 13 6
9 11 10
5 0 6
6 10 1
5 13 6
11 15 1
14 8 6
8 6 1
6 3 6
0 8 7
3 14 7
17 9 1
0 6 6
14 13 1
1 14 8
13 3 7
1 3 1
16 14 1
1 0 6
13 6 6

output:

20

result:

ok single line: '20'

Test #30:

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

input:

18 40
11 3 7
3 8 6
10 3 6
10 8 6
9 5 1
17 4 1
12 11 6
11 10 6
2 16 1
3 7 1
8 15 6
6 15 7
2 13 1
8 11 1
1 11 6
11 14 9
5 15 18
1 14 11
13 4 1
6 12 6
15 11 6
1 10 6
8 6 6
9 7 1
3 12 6
11 6 6
10 14 6
15 1 6
6 1 1
12 15 1
0 11 6
10 6 6
15 10 1
1 3 1
14 5 1
9 4 1
14 15 6
17 12 1
16 0 1
14 8 1

output:

22

result:

ok single line: '22'

Test #31:

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

input:

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

output:

19

result:

ok single line: '19'

Test #32:

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

input:

9 14
0 7 3
1 4 1
8 7 3
3 0 1
8 5 1
4 6 1
4 3 1
0 8 3
5 4 1
2 0 3
8 2 3
7 2 3
1 2 1
6 7 1

output:

11

result:

ok single line: '11'

Test #33:

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

input:

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

output:

24

result:

ok single line: '24'

Test #34:

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

input:

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

output:

24

result:

ok single line: '24'

Subtask #3:

score: 2
Accepted

Test #35:

score: 2
Accepted
time: 2499ms
memory: 71836kb

input:

5000 10000
1867 4363 2515
262 989 2506
22 808 1
3969 1940 1
301 4586 2912
2193 1408 1
2656 3426 2589
643 4376 2570
4986 4031 1
2149 538 2636
1662 183 2518
3111 3252 2885
3710 216 2679
4540 11 1
4690 3663 1
3549 4010 2666
2480 3321 1
216 15 2530
1228 3212 2965
1923 1417 2724
3832 1842 2649
3937 1191 ...

output:

4999

result:

ok single line: '4999'

Test #36:

score: 0
Accepted
time: 2496ms
memory: 71576kb

input:

4999 10000
1811 2026 2694
3479 3673 2663
1418 2998 2511
1533 746 1
3141 2435 1
8 3832 1
3350 4951 1
3866 1685 1
3174 803 1
4859 2198 3111
2532 3104 1
360 2983 3434
4810 661 1
3196 3277 1
3766 4511 1
4665 38 1
3829 3722 1
3669 3100 1
3779 3560 3109
2532 257 1
4494 1302 3212
2300 4182 1
1122 2796 1
41...

output:

4998

result:

ok single line: '4998'

Test #37:

score: 0
Accepted
time: 2488ms
memory: 72412kb

input:

4999 10000
4535 296 2529
4754 1564 2631
4255 1701 1
4776 1038 1
4180 3807 2633
2924 1082 2508
372 51 2899
2041 2754 2524
1976 3391 2563
4103 4955 2566
419 840 1
355 1999 2504
3726 2488 2587
728 836 1
355 97 2501
2852 1901 2503
4034 2911 1
2202 2453 1
3239 327 2778
436 686 1
2370 1022 2514
3866 3929 ...

output:

6664

result:

ok single line: '6664'

Test #38:

score: 0
Accepted
time: 2500ms
memory: 70872kb

input:

4998 10000
4160 4537 1
3358 2521 1
2897 4536 1
2004 3684 1
543 139 3825
641 1841 3630
4934 3527 3118
144 2651 1
2185 3663 1
3382 2931 1
1095 3978 1
3934 1384 3439
3777 1089 2697
4732 591 3854
717 4222 3394
88 1043 1
1606 1970 1
2491 2131 2813
4924 1126 2662
1001 440 3886
369 1061 1
2667 2847 1
4975 ...

output:

7495

result:

ok single line: '7495'

Test #39:

score: 0
Accepted
time: 2499ms
memory: 70832kb

input:

4998 10000
2997 3161 1
3664 4692 2648
3671 4617 1
1427 3471 1
3455 3660 2810
3979 2418 1
4606 471 1
1809 3050 2728
1531 3037 1
2254 4415 1
2445 1898 1
2772 3275 1
2729 204 4604
1485 1625 4570
971 3747 4039
2616 1632 3080
4925 3300 1
4045 4637 4115
456 4869 1
2662 4208 1
745 195 1
2497 1663 1
669 651...

output:

7994

result:

ok single line: '7994'

Test #40:

score: 0
Accepted
time: 2500ms
memory: 71428kb

input:

5000 10000
3294 692 1
3294 883 1
3294 57 1
3294 3972 1
3294 3107 1
13 3294 1
4039 4508 2813
4074 4356 4511
760 3294 1
3294 215 1
2281 834 3509
1861 2733 2852
1716 2215 3549
640 3294 1
3294 2215 1
4044 3628 3386
3294 4396 1
2276 3599 3982
1855 2120 3761
4620 2792 2622
259 4461 3361
3294 1794 1
2792 1...

output:

9996

result:

ok single line: '9996'

Test #41:

score: 0
Accepted
time: 2492ms
memory: 71008kb

input:

4998 10000
2037 3029 2962
3529 1776 3256
4052 2853 3389
130 1776 3070
3630 2951 1
4846 4531 1
2204 1792 2814
3532 2181 3077
2070 1549 2825
630 2837 1
1172 525 2657
1503 346 1
2772 2432 1
4351 3852 1
991 3154 1
4161 3636 1
1533 3782 1
3839 0 3253
4107 1724 1
2371 441 1
2490 1476 2514
1344 4103 1
1101...

output:

5002

result:

ok single line: '5002'

Test #42:

score: 0
Accepted
time: 2500ms
memory: 71812kb

input:

4998 10000
3604 2415 2552
2999 4014 1
2138 3572 2677
4902 1482 1
2339 217 1
638 1323 2662
3600 2998 2506
231 2582 2707
2491 4955 2625
1746 4277 2541
3886 4104 2525
506 1917 2808
4810 3721 1
4841 4081 2551
3925 4360 1
3754 572 1
2777 848 1
4582 864 1
149 2112 2518
2848 1445 1
2681 3254 1
4412 2967 1
...

output:

6776

result:

ok single line: '6776'

Test #43:

score: 0
Accepted
time: 2496ms
memory: 72048kb

input:

4998 10000
1996 2117 3222
4177 4126 3634
1011 1208 2930
2923 3872 2536
4677 2176 1
1239 3704 2689
2726 1986 3364
2985 3118 3279
2271 864 2864
2811 3508 2633
3823 1193 3210
1880 4435 1
867 3420 2632
3687 2910 2730
2020 1769 1
751 2339 1
3410 3910 1
4518 342 2872
1720 1404 1
4945 393 1
4904 4175 1
224...

output:

5593

result:

ok single line: '5593'

Test #44:

score: 0
Accepted
time: 2496ms
memory: 71256kb

input:

4998 10000
4804 28 3849
721 2739 2696
1788 1153 1
1598 2007 4146
1345 473 1
1248 1922 2542
517 181 1
4284 3809 2836
860 2718 1
4738 4912 1
2821 4331 1
2375 10 1
2943 2609 3226
3904 389 1
3526 4773 1
2682 1300 1
3221 4571 1
2174 2709 1
1695 2472 3412
3958 480 2568
504 1749 3134
2926 2134 3838
2429 18...

output:

7495

result:

ok single line: '7495'

Test #45:

score: 0
Accepted
time: 2491ms
memory: 72608kb

input:

4995 10000
4894 4404 1
2663 3250 3525
1794 3573 3400
4352 2925 2570
4816 3505 2629
4661 613 2539
3418 1376 1
1745 1017 2603
1169 347 1
3945 2997 1
879 1344 3492
4133 2070 1
2116 3625 1
3067 4194 2529
4804 2777 3108
724 879 1
3508 961 1
3708 3515 4459
869 557 1
44 1412 1
4587 2950 3157
1307 2506 1
30...

output:

6662

result:

ok single line: '6662'

Test #46:

score: 0
Accepted
time: 2504ms
memory: 71196kb

input:

4989 10000
308 3531 2495
3166 214 1
1550 4139 1
75 3098 1
4700 3912 2495
2472 4255 1
1380 72 1
4375 3042 1
2030 4261 2495
4180 3405 2495
2319 2501 1
1492 3741 1
81 187 1
1327 4535 2495
3405 1851 2495
3515 342 1
2043 3674 1
1680 314 1
3405 2295 2495
1802 349 2495
2366 1840 2495
349 3442 2495
4149 471...

output:

7482

result:

ok single line: '7482'

Test #47:

score: 0
Accepted
time: 2495ms
memory: 73028kb

input:

4995 10000
1724 2508 2874
3718 883 2875
1904 2406 1
4855 4627 1
4863 2837 3750
1486 3234 2687
2590 991 3054
3973 1844 3072
2746 2554 1
1093 1639 1
2472 3348 2892
3552 4957 2597
4871 2257 1
2536 4347 3340
4160 1715 4061
930 821 1
645 2536 3428
526 468 3190
4391 3086 4118
712 1277 3042
3277 3971 1
385...

output:

6662

result:

ok single line: '6662'

Test #48:

score: 0
Accepted
time: 2501ms
memory: 71460kb

input:

4995 10000
3624 3363 2859
668 4378 2564
488 2100 2994
814 645 3044
3264 3878 2525
3723 2062 1
2701 4514 1
1175 9 1
4659 789 3293
4185 144 1
4898 4832 3146
3360 2869 2505
737 2906 1
2244 2587 1
1540 4658 3620
1803 1598 1
4369 3944 1
38 340 3773
4619 2493 1
1656 4768 3059
3037 2314 1
3890 4371 2647
15...

output:

6662

result:

ok single line: '6662'

Subtask #4:

score: 6
Accepted

Test #49:

score: 6
Accepted
time: 7ms
memory: 70632kb

input:

100 200
98 79 1
40 18 1
45 56 1
23 26 39
88 51 1
49 31 35
55 85 1
5 71 35
88 38 36
30 90 38
73 90 39
83 65 1
80 18 35
91 27 35
39 66 1
96 23 34
30 40 36
60 41 1
78 22 1
25 97 42
98 40 43
33 7 35
58 13 1
7 84 1
4 16 70
88 99 1
24 36 1
40 26 37
30 79 1
27 44 1
44 12 42
84 37 54
50 69 35
18 89 1
93 29 ...

output:

99

result:

ok single line: '99'

Test #50:

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

input:

99 200
47 6 34
5 83 1
22 66 1
40 8 1
17 73 42
52 98 40
80 74 75
82 94 45
35 74 1
32 48 1
75 26 55
59 87 1
14 60 37
68 76 62
30 45 46
56 21 1
74 83 74
68 60 35
40 74 1
68 79 41
10 78 1
16 76 51
85 60 60
33 8 45
70 0 1
86 83 49
3 20 1
3 36 1
86 38 33
9 52 45
15 38 33
93 0 1
93 82 1
98 37 60
50 18 1
33...

output:

98

result:

ok single line: '98'

Test #51:

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

input:

100 200
86 2 1
20 32 1
3 16 1
71 28 52
90 70 1
24 74 1
70 51 34
67 38 48
45 28 38
55 44 1
22 65 38
97 27 37
18 69 1
13 49 1
84 99 1
60 4 39
78 56 1
47 79 1
48 68 40
31 29 1
82 51 40
82 74 41
22 44 35
21 67 35
45 86 51
25 21 36
12 24 53
81 26 1
69 75 1
70 33 1
36 2 36
20 62 1
65 45 35
91 41 1
21 60 4...

output:

132

result:

ok single line: '132'

Test #52:

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

input:

99 200
22 41 33
25 16 1
3 32 1
56 32 38
19 3 37
68 6 36
90 8 37
30 92 33
80 3 37
90 67 34
41 73 37
45 60 1
76 59 1
68 87 35
9 92 36
96 36 1
73 5 33
30 32 33
92 45 33
64 30 1
16 57 1
17 47 1
11 30 36
97 92 41
46 68 1
97 94 37
90 2 34
67 23 1
80 23 40
86 21 1
82 48 1
67 84 38
2 67 35
73 88 1
87 67 37
...

output:

133

result:

ok single line: '133'

Test #53:

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

input:

99 200
8 5 33
12 88 35
14 71 33
55 53 35
53 91 1
60 26 1
10 8 34
39 94 1
5 53 33
86 16 1
13 36 1
50 62 1
87 89 33
20 26 1
88 73 1
16 82 1
48 67 1
63 72 1
0 12 33
35 94 1
8 28 33
8 52 33
15 75 1
63 0 33
40 28 33
42 41 1
52 87 1
47 14 34
40 71 33
47 71 33
71 63 33
85 95 1
29 38 1
37 69 1
32 24 1
55 14...

output:

150

result:

ok single line: '150'

Test #54:

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

input:

100 200
61 67 71
45 95 35
37 77 58
66 59 79
80 6 1
16 39 90
19 4 46
18 45 60
18 77 61
6 18 1
26 50 91
6 2 1
57 66 46
86 6 1
16 40 40
95 37 52
61 30 62
93 9 52
36 76 39
78 72 91
54 60 51
6 37 1
84 38 57
35 80 40
68 10 39
6 62 1
71 42 78
6 59 1
98 69 67
6 36 1
56 48 46
6 34 1
6 26 1
1 25 56
38 6 1
6 2...

output:

196

result:

ok single line: '196'

Test #55:

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

input:

99 200
50 52 1
40 30 1
41 33 1
95 97 1
51 29 1
92 42 51
25 23 49
76 89 1
7 69 39
45 70 1
74 49 55
49 25 36
6 17 57
66 27 1
48 26 51
18 85 41
87 83 67
58 2 36
85 38 1
13 36 41
26 74 35
41 61 64
50 58 39
69 41 1
42 17 1
0 55 1
93 85 1
49 6 1
85 96 36
42 69 62
67 1 1
51 3 1
48 36 58
19 66 1
33 87 39
9 ...

output:

99

result:

ok single line: '99'

Test #56:

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

input:

99 200
51 10 1
72 59 35
26 82 34
80 20 33
65 87 1
34 79 33
78 49 1
56 6 33
13 27 34
60 78 1
41 46 1
5 0 34
52 49 1
86 94 35
69 36 1
71 77 1
64 75 1
82 7 39
27 22 35
54 37 1
96 46 1
16 38 1
13 83 35
80 60 1
26 86 44
81 35 1
31 14 1
79 20 56
54 47 33
96 73 1
0 41 34
60 19 1
2 95 34
26 29 37
22 37 33
4...

output:

133

result:

ok single line: '133'

Test #57:

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

input:

99 200
48 82 1
81 46 1
7 41 1
8 7 1
28 89 34
74 14 34
15 47 35
94 89 38
63 20 44
32 39 41
49 14 1
83 2 1
63 41 34
36 20 39
68 9 1
80 75 1
23 39 39
20 89 49
68 14 35
28 39 1
11 63 1
36 3 34
64 9 35
9 20 36
12 10 1
45 2 36
23 14 56
71 74 33
32 20 37
20 23 46
72 86 1
45 68 59
54 94 1
95 2 1
45 51 1
33 ...

output:

110

result:

ok single line: '110'

Test #58:

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

input:

96 200
91 78 1
94 25 42
59 66 1
7 36 1
68 16 33
46 16 1
94 81 35
50 16 33
93 48 1
29 60 1
58 42 1
37 81 33
63 1 32
28 41 1
17 78 1
33 71 1
68 74 33
8 5 1
21 25 40
35 23 37
85 23 33
57 73 1
90 95 1
13 67 33
75 32 38
82 46 1
21 69 33
22 39 1
38 5 1
43 75 32
79 82 32
43 13 1
92 83 1
1 75 1
38 36 1
23 1...

output:

126

result:

ok single line: '126'

Test #59:

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

input:

99 200
11 6 36
54 82 1
61 84 1
56 90 1
17 73 1
5 17 37
34 6 38
81 74 34
27 88 1
42 25 1
30 16 1
10 46 36
25 39 1
27 82 36
59 82 33
7 1 1
22 29 40
38 94 34
22 74 33
76 8 1
98 5 37
22 38 34
27 77 34
59 24 1
45 44 1
18 28 1
62 67 1
86 26 1
31 41 1
54 88 36
4 70 35
9 98 34
90 65 1
32 97 1
98 16 38
29 98...

output:

131

result:

ok single line: '131'

Test #60:

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

input:

93 200
30 84 38
21 61 1
54 33 1
79 3 1
2 19 1
85 75 40
48 31 1
50 77 40
62 34 1
10 88 38
23 92 1
73 72 1
77 46 41
47 41 41
77 84 40
77 65 42
1 84 1
1 78 39
45 52 1
41 10 42
5 74 1
85 24 42
1 88 39
65 88 40
75 50 40
10 67 41
1 77 41
41 1 43
91 10 42
81 90 1
51 26 1
65 50 41
76 85 42
88 70 40
67 70 43...

output:

136

result:

ok single line: '136'

Test #61:

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

input:

98 113
56 17 1
75 59 1
23 42 34
74 81 1
95 75 1
48 30 1
36 42 1
0 26 1
27 68 1
95 76 1
45 33 1
5 9 1
80 78 1
85 18 1
44 23 39
23 81 41
52 24 1
53 49 1
91 23 36
4 63 1
65 3 1
89 6 1
64 85 1
36 23 35
20 32 1
58 72 1
23 54 37
64 9 1
46 7 1
37 96 1
31 69 1
23 32 44
17 57 1
70 23 38
54 91 1
28 57 1
74 44...

output:

144

result:

ok single line: '144'

Test #62:

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

input:

98 113
75 80 1
10 31 1
26 90 1
34 0 1
17 55 1
16 9 1
86 27 1
46 63 1
34 54 1
45 22 1
24 59 1
44 30 38
70 73 1
29 35 1
36 53 1
11 37 1
26 70 1
94 25 1
18 66 1
13 31 1
79 47 1
6 84 1
84 56 1
30 69 1
90 44 35
83 21 1
72 28 1
82 36 1
71 44 1
74 9 1
3 41 1
44 91 42
90 97 1
37 68 1
83 76 1
72 15 1
19 1 1
...

output:

144

result:

ok single line: '144'

Subtask #5:

score: 2
Accepted

Test #63:

score: 2
Accepted
time: 56ms
memory: 70728kb

input:

500 1000
208 211 175
291 249 178
221 407 234
95 379 1
455 400 1
28 217 1
488 93 1
398 101 191
382 222 184
407 77 191
183 471 1
306 466 1
174 78 175
391 180 167
432 486 1
414 284 171
436 446 1
34 294 1
38 110 1
41 186 1
148 336 1
85 33 1
491 114 171
22 197 1
385 388 183
245 41 176
423 257 1
100 203 1...

output:

499

result:

ok single line: '499'

Test #64:

score: 0
Accepted
time: 58ms
memory: 68636kb

input:

499 1000
129 32 1
83 112 369
275 120 1
123 382 168
316 326 244
238 349 257
7 103 207
21 468 319
479 269 1
156 66 1
312 351 1
80 299 1
413 306 1
155 240 1
306 87 305
67 188 188
481 271 230
122 77 1
285 491 1
120 247 288
454 158 1
12 459 1
447 139 1
429 399 308
217 200 1
87 468 195
93 81 1
405 165 187...

output:

498

result:

ok single line: '498'

Test #65:

score: 0
Accepted
time: 56ms
memory: 69456kb

input:

499 1000
179 207 191
269 207 167
454 87 1
258 456 1
267 19 1
400 387 1
261 326 1
383 246 219
193 388 198
219 278 173
476 71 1
331 289 1
36 427 194
152 285 221
352 419 1
325 5 1
104 89 1
67 279 178
445 300 1
486 280 201
414 486 231
339 435 1
346 21 1
384 3 1
369 362 1
297 416 1
498 408 1
55 374 1
460...

output:

664

result:

ok single line: '664'

Test #66:

score: 0
Accepted
time: 63ms
memory: 70240kb

input:

498 1000
448 224 187
395 147 1
241 251 1
95 443 168
240 273 166
363 15 1
128 157 182
304 461 176
387 305 1
165 72 182
213 410 175
325 187 1
242 86 189
135 181 1
80 262 181
203 293 1
287 434 170
128 301 170
88 86 194
472 288 174
32 239 1
339 103 1
497 417 168
448 288 1
234 51 174
55 382 186
326 444 1...

output:

663

result:

ok single line: '663'

Test #67:

score: 0
Accepted
time: 60ms
memory: 70116kb

input:

498 1000
60 57 1
362 208 169
401 481 167
352 175 166
314 159 1
352 162 1
248 125 1
122 285 1
75 249 1
364 413 168
464 390 167
374 229 1
5 87 168
225 341 1
345 146 1
248 370 175
240 288 1
259 454 166
481 122 175
253 59 173
382 463 1
85 175 170
205 129 1
2 108 1
155 25 175
80 425 166
96 136 1
157 247 ...

output:

765

result:

ok single line: '765'

Test #68:

score: 0
Accepted
time: 62ms
memory: 69160kb

input:

500 1000
183 283 1
324 285 207
283 231 1
329 283 1
283 1 1
476 52 232
110 283 1
9 434 272
358 372 250
204 460 301
283 346 1
283 238 1
476 283 1
435 357 243
3 273 208
283 138 1
489 140 206
295 495 191
446 283 1
159 96 168
441 298 173
32 283 1
146 254 198
283 165 1
418 312 373
293 259 290
388 105 435
...

output:

996

result:

ok single line: '996'

Test #69:

score: 0
Accepted
time: 56ms
memory: 70092kb

input:

498 1000
467 252 236
383 281 1
146 417 228
399 206 1
273 68 1
66 40 1
300 404 233
275 150 248
196 432 1
221 303 167
169 486 193
470 22 258
7 245 1
226 35 1
330 317 179
409 219 1
372 244 1
58 475 1
330 252 218
87 393 178
107 23 1
447 289 166
70 342 259
337 144 171
358 144 1
171 74 171
266 443 1
30 54...

output:

500

result:

ok single line: '500'

Test #70:

score: 0
Accepted
time: 62ms
memory: 69540kb

input:

498 1000
91 363 177
422 37 196
215 132 1
141 212 1
126 422 173
84 160 180
268 49 1
266 1 1
399 79 1
205 254 173
219 90 167
283 236 1
47 481 1
478 400 1
180 86 1
298 17 1
345 149 1
426 130 1
81 447 187
253 400 1
88 282 1
464 463 1
180 477 1
209 5 169
452 383 207
368 80 1
447 257 176
402 362 1
456 96 ...

output:

668

result:

ok single line: '668'

Test #71:

score: 0
Accepted
time: 55ms
memory: 68872kb

input:

498 1000
100 273 166
355 495 249
268 311 1
355 280 175
267 245 1
324 160 246
224 348 1
418 313 1
417 98 180
55 304 1
246 389 1
462 478 167
469 79 1
446 260 167
417 446 167
218 488 177
427 385 173
117 485 1
376 107 1
175 311 1
252 200 1
206 83 1
481 36 186
196 88 1
418 222 1
221 320 169
221 252 171
3...

output:

557

result:

ok single line: '557'

Test #72:

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

input:

498 1000
24 201 1
369 454 166
347 38 1
405 3 1
106 39 1
464 229 1
255 457 168
391 165 200
416 93 1
134 176 178
1 134 172
332 422 1
330 373 1
35 384 1
148 194 1
85 358 1
222 137 1
430 245 182
466 325 166
374 16 169
206 125 1
257 40 218
259 159 182
104 207 1
15 468 194
196 307 171
247 381 179
27 497 1...

output:

662

result:

ok single line: '662'

Test #73:

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

input:

495 1000
431 197 1
399 289 1
72 218 1
77 74 169
473 243 1
38 127 170
465 391 171
460 161 190
270 424 200
492 400 169
34 333 1
47 40 219
137 180 1
398 390 1
261 105 1
467 14 1
424 409 168
70 305 1
383 309 170
179 302 1
17 29 230
128 182 175
490 247 1
373 341 1
63 433 1
37 264 178
15 159 1
456 341 192...

output:

661

result:

ok single line: '661'

Test #74:

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

input:

489 1000
290 274 238
143 252 232
355 358 1
190 108 226
86 219 226
107 245 238
290 169 235
106 332 1
384 413 1
379 246 1
92 231 238
12 284 1
432 10 1
184 404 230
231 380 239
274 366 235
40 52 1
353 209 241
252 365 231
366 252 229
311 2 228
219 184 229
92 95 231
311 220 234
150 169 237
124 86 233
12 1...

output:

730

result:

ok single line: '730'

Test #75:

score: 0
Accepted
time: 58ms
memory: 69824kb

input:

498 580
389 339 1
229 468 1
92 411 1
422 190 1
156 467 1
258 291 1
408 372 1
239 467 1
418 386 1
375 109 1
217 478 174
68 388 1
199 401 1
263 6 1
159 172 1
331 271 1
264 217 175
168 471 1
40 315 1
227 336 1
229 217 167
217 433 188
46 449 1
366 230 1
140 23 1
471 217 244
0 445 1
322 267 1
389 217 246...

output:

744

result:

ok single line: '744'

Test #76:

score: 0
Accepted
time: 56ms
memory: 70488kb

input:

498 580
118 36 1
211 195 1
342 278 1
479 19 1
420 285 1
348 396 1
92 389 1
489 260 1
76 185 173
462 2 1
341 453 1
421 81 1
213 317 1
435 428 1
45 484 1
185 464 222
133 18 1
264 165 1
48 253 1
319 110 1
104 225 1
486 128 1
185 14 213
185 398 1
324 109 1
143 185 197
488 215 1
386 22 1
71 479 1
112 396...

output:

744

result:

ok single line: '744'

Subtask #6:

score: 3
Accepted

Test #77:

score: 3
Accepted
time: 2487ms
memory: 72664kb

input:

5000 10000
1233 3822 1672
230 3287 1
3304 542 1
4203 4319 1
3890 46 1
1145 4330 1865
4631 4227 1667
3806 541 1
3145 196 1846
2583 4656 1
2526 3928 1
1339 2914 1
448 438 1945
3691 4076 2605
2115 2224 1727
3050 4573 1876
334 4820 1725
4792 2439 1
279 787 1
3592 4602 1704
3634 3783 1
4822 424 1687
1546...

output:

4999

result:

ok single line: '4999'

Test #78:

score: 0
Accepted
time: 2488ms
memory: 74324kb

input:

4999 10000
1536 2256 2503
1838 4182 1
4242 4573 1
4453 4031 2797
4843 4842 2784
701 2457 1906
1106 324 2586
4432 424 3795
496 930 2340
2468 1024 1
2922 4574 1882
1640 4939 1
2452 2963 1
1659 308 1
346 1011 1
2490 2062 1
3519 664 1
1252 1603 1
1095 737 1
3444 573 1
4448 1092 1
262 4248 3240
4244 1059...

output:

4998

result:

ok single line: '4998'

Test #79:

score: 0
Accepted
time: 2496ms
memory: 71652kb

input:

4999 10000
1756 464 1
2256 3527 1779
3158 662 1979
648 4209 1
131 4844 2373
4768 1977 1
4338 2206 1
3900 1283 1764
3656 4458 1
642 1292 1
3377 1257 1734
3228 4789 1
2418 3295 2112
4489 3040 1947
4604 4945 2171
1761 4027 1
1770 88 1
4217 1453 1
4732 4196 2069
2042 2568 1
172 286 2163
1578 4021 2125
1...

output:

6664

result:

ok single line: '6664'

Test #80:

score: 0
Accepted
time: 2496ms
memory: 72580kb

input:

4998 10000
1903 2765 1
632 985 1726
4097 2231 2043
3670 1055 1690
95 336 1
4153 3229 1
3338 3891 1
774 4667 1
3384 834 1
2304 3193 1667
1991 4811 1
1566 764 1
1509 2702 1
4769 1895 1
2116 2290 1865
1030 2843 1700
3653 3081 1
4269 4090 1
3591 213 1
2069 2206 1
3987 2621 1
3694 427 1760
2443 4937 2065...

output:

6694

result:

ok single line: '6694'

Test #81:

score: 0
Accepted
time: 2491ms
memory: 71288kb

input:

4998 10000
3685 2000 1795
347 808 1677
1317 3676 1
4330 4835 1848
2339 3726 1
1738 1448 1704
3164 4244 1680
2602 1337 1
4651 221 1680
4006 4719 1
3294 2588 1693
57 1188 1753
4040 3954 1
2049 859 1
3893 2336 1
4529 4326 1
2453 1180 1731
3709 1763 1758
393 3252 1670
4964 4996 1679
183 1151 1686
300 41...

output:

7684

result:

ok single line: '7684'

Test #82:

score: 0
Accepted
time: 2496ms
memory: 71700kb

input:

5000 10000
1703 3551 3427
2741 621 2096
1444 3037 1
583 1888 2921
891 1444 1
878 1253 2614
198 1444 1
85 3949 3728
2561 670 1816
2098 1444 1
4142 1444 1
3762 1195 1764
2021 4108 3038
4304 4697 1804
4786 4642 3981
2780 527 2835
1317 2613 3294
4038 1444 1
1444 2411 1
1444 3015 1
1831 4615 4303
1444 44...

output:

9996

result:

ok single line: '9996'

Test #83:

score: 0
Accepted
time: 2491ms
memory: 72576kb

input:

4998 10000
1698 2942 1
3346 1246 1
4072 3044 2334
2220 3866 1
4281 3261 1698
3195 3418 1
3737 4370 1
1923 2231 1827
485 3011 1851
3498 3261 1831
2013 2949 1
3010 79 2316
4304 2593 1
3840 3966 1945
470 1912 1875
4793 3546 2257
886 84 1958
446 2848 2882
2159 105 2735
1285 446 1
2923 2426 2186
3510 132...

output:

5003

result:

ok single line: '5003'

Test #84:

score: 0
Accepted
time: 2501ms
memory: 71648kb

input:

4998 10000
545 1414 2056
3567 3566 1854
3901 1112 1
4477 3533 1
4981 4769 1697
2916 1786 1
1484 4522 1739
3036 3778 2432
4474 4463 1739
1303 3590 1686
2542 2872 1
451 4635 1903
1105 3308 1
3345 4928 1
4722 2334 1
3961 2272 1815
4346 3172 1
437 4481 1675
1849 4438 1
3624 4927 1714
1683 4289 2133
901 ...

output:

6737

result:

ok single line: '6737'

Test #85:

score: 0
Accepted
time: 2492ms
memory: 71136kb

input:

4998 10000
4734 3298 1
3774 2334 1
3265 2054 1
3745 121 1
3117 226 2134
3435 1332 2496
4309 711 1
2425 1850 1
2223 3256 1
2984 1586 1
1223 4036 1
4042 1044 1
4828 125 1
175 3117 1704
2280 1716 2009
1343 3614 1
1983 2067 1
920 2193 2292
1405 3788 1
3893 4244 1746
4122 1789 2468
4930 537 1729
2311 273...

output:

5552

result:

ok single line: '5552'

Test #86:

score: 0
Accepted
time: 2499ms
memory: 71680kb

input:

4998 10000
637 1778 1809
4148 4485 1
4245 903 1947
2795 1057 1
1694 995 1880
1433 4229 1
694 3670 1857
1965 4116 1754
3122 4596 2003
3161 2576 1778
3710 883 1
3418 4062 2029
1920 2551 1
280 4136 1756
4496 4178 1
1184 4696 1
2845 3705 2043
3866 557 1
3321 3961 1
1841 2459 1702
623 1147 1
130 4341 1
3...

output:

6662

result:

ok single line: '6662'

Test #87:

score: 0
Accepted
time: 2492ms
memory: 73980kb

input:

4995 10000
2123 4290 1
1201 4398 1889
3262 2537 1
2241 4502 1
11 752 1
4777 2316 1685
2260 979 1
4730 847 1
390 4543 1
1460 3748 1838
1916 3745 1758
628 3668 1
3029 4170 1
4421 1194 1687
2716 2670 1
1900 399 1693
3058 4818 1
1496 2014 1
3804 4077 1
3227 1776 1
2099 485 1
26 3146 1
721 3233 2111
2324...

output:

6661

result:

ok single line: '6661'

Test #88:

score: 0
Accepted
time: 2487ms
memory: 72228kb

input:

4989 10000
3146 235 1
3085 2260 1
3600 412 2447
3947 4579 1
883 864 2469
3396 4800 2474
245 1192 1
957 577 1
1647 2746 1
3396 4349 2457
2644 3600 2460
1482 676 1
4238 37 2441
472 2373 2474
1257 3514 2438
2224 4224 1
4780 2611 2481
4123 3474 2466
2219 3389 1
2966 3656 1
1131 2176 2478
3460 2 1
4059 3...

output:

7480

result:

ok single line: '7480'

Test #89:

score: 0
Accepted
time: 2491ms
memory: 72096kb

input:

4998 5830
3687 2056 1
1857 4350 1
4565 1242 1
4637 606 1
2645 1120 1993
969 564 1
1048 2992 1
3190 1010 1
4921 1279 1
1120 3571 2273
376 654 1
33 1410 1
2544 1120 1883
791 1120 2096
2807 4222 1
3018 962 1
2167 1375 1
4851 2370 1
45 4381 1
4730 476 1
4374 940 1
461 1120 2196
2890 2011 1
987 4679 1
34...

output:

7494

result:

ok single line: '7494'

Test #90:

score: 0
Accepted
time: 2496ms
memory: 72428kb

input:

4998 5830
4987 1353 1
1873 1330 1
202 2149 1
4818 2774 1
1973 4434 1
2738 4763 1
1306 4653 1
2219 4746 1
3387 4631 1
4588 3439 1
1990 1245 1
686 3052 1
1450 1959 1826
4535 4171 1
1959 4266 2386
2917 1800 1
2280 1341 1
4933 37 1
1184 4230 1
1959 4176 1953
4843 809 1
459 1285 1
1959 1203 2181
892 1264...

output:

7494

result:

ok single line: '7494'

Subtask #7:

score: 5
Accepted

Test #91:

score: 5
Accepted
time: 2505ms
memory: 103200kb

input:

79998 160000
47319 43920 27006
37874 58542 1
2314 12853 1
36506 22858 26740
68911 13350 31720
25597 38100 1
64407 54997 1
51674 45889 26896
6348 21021 1
20123 37354 1
40529 9510 1
17862 77380 1
33670 44212 1
49850 17554 1
66696 36952 26977
68826 79479 1
57060 12489 1
5752 45575 1
7053 19904 26742
66...

output:

106662

result:

ok single line: '106662'

Test #92:

score: 0
Accepted
time: 2517ms
memory: 105216kb

input:

79995 160000
61320 66228 31633
20416 6828 26745
65430 51513 28853
61601 77927 1
33775 10749 30386
33489 57662 28107
65564 42605 1
72503 58487 28031
24791 62445 1
361 36744 31994
6993 12131 1
38636 9267 30756
50189 3424 27481
21764 13079 27045
13091 75180 1
76213 1089 29713
29054 60322 28242
6840 342...

output:

106661

result:

ok single line: '106661'

Test #93:

score: 0
Accepted
time: 2537ms
memory: 102512kb

input:

79989 160000
32970 17371 1
51500 77845 1
8694 39321 1
33402 55053 1
3593 13400 1
25018 73843 1
10116 78323 39829
12333 8162 1
77825 52478 39800
71287 49773 39857
69284 34436 1
58422 323 1
71978 34401 1
32727 4966 39931
17840 59434 1
78584 5862 1
33173 8137 39835
35430 76217 1
77630 21975 1
39606 180...

output:

119980

result:

ok single line: '119980'

Test #94:

score: 0
Accepted
time: 2525ms
memory: 102904kb

input:

79998 93330
39579 27063 1
48572 35446 1
40362 9364 28215
28842 18275 1
71735 67469 1
76515 33620 1
30996 48788 1
14552 9364 36309
77625 2707 1
1342 19383 1
5882 66210 1
73150 46423 1
75551 4187 1
43266 70746 1
71784 32162 1
79762 69551 1
48566 46786 1
9364 34906 38002
21007 73310 1
39475 66834 1
375...

output:

119994

result:

ok single line: '119994'

Test #95:

score: 0
Accepted
time: 2510ms
memory: 102092kb

input:

79998 93330
6540 36912 1
6828 67666 1
64532 68447 1
71308 47069 1
28144 17430 1
74171 26737 1
37891 59511 38136
13928 72394 1
10800 18697 1
78179 63555 1
58591 59292 1
68147 62982 1
35098 75561 1
18417 43389 1
26115 70392 1
43212 11367 1
34505 67384 1
13934 74906 1
13688 59511 31890
47362 59511 2850...

output:

119994

result:

ok single line: '119994'

Test #96:

score: 0
Accepted
time: 2516ms
memory: 108368kb

input:

80000 160000
18646 25309 31117
75880 22684 26801
9589 30212 28588
75855 59124 26759
39977 32801 1
33356 51569 1
32561 7906 28071
50960 76844 31594
67 53601 1
33104 4508 1
77268 6010 26897
78324 71277 1
60358 32572 27870
6192 39931 33107
47020 32401 37620
7263 48001 1
66559 43096 27554
40677 31787 1
...

output:

79999

result:

ok single line: '79999'

Test #97:

score: 0
Accepted
time: 2538ms
memory: 106900kb

input:

79999 160000
24942 30968 1
52955 71005 26826
46890 43341 1
18100 66202 1
68417 13241 1
66471 79814 27146
74673 44182 1
7913 53962 29100
25698 9147 1
39604 48948 30410
71267 8338 1
53847 54500 1
67757 40624 32934
44367 72934 1
53487 28998 1
31093 66648 1
40690 3748 30034
26240 75595 29035
10172 42680...

output:

79998

result:

ok single line: '79998'

Test #98:

score: 0
Accepted
time: 2525ms
memory: 104996kb

input:

79999 160000
68371 12363 1
66033 66837 1
54751 63697 1
47334 55960 1
42742 12344 1
26282 22385 1
4354 70183 1
64445 16533 28453
29298 79678 33046
9031 16502 33273
11898 10444 31740
42661 63249 32839
54569 42878 1
26197 16893 1
36502 29265 1
70474 72121 1
26016 60327 27238
33290 10560 1
14981 36785 1...

output:

106664

result:

ok single line: '106664'

Test #99:

score: 0
Accepted
time: 2525ms
memory: 100808kb

input:

79998 160000
49893 4194 1
4696 76156 27499
32221 12779 1
62525 74247 1
61023 30145 1
22601 55492 27254
44592 9237 30709
19697 26616 28490
63005 35043 27375
11395 57328 29945
63615 5287 1
24215 74993 1
30468 13440 28768
73146 19450 27582
688 20996 26921
42088 70035 26739
74337 55339 1
64143 66943 280...

output:

106922

result:

ok single line: '106922'

Test #100:

score: 0
Accepted
time: 2530ms
memory: 102192kb

input:

79998 160000
12170 50959 1
54379 56074 27005
71771 996 1
46444 41033 26754
58154 44763 1
72805 76221 1
77432 10847 1
71616 23083 27399
58535 42287 1
393 69414 29808
46763 31366 1
56213 32205 1
67320 46156 28550
43867 10597 1
48746 25099 1
66687 33606 1
21205 2493 28197
65491 9462 1
46160 57648 27723...

output:

122793

result:

ok single line: '122793'

Test #101:

score: 0
Accepted
time: 2514ms
memory: 98052kb

input:

80000 160000
9995 8435 28351
25856 1588 1
14575 62114 27253
42365 58590 38176
23296 1588 1
1588 72349 1
9926 1588 1
44415 2348 48183
1588 67333 1
50838 29931 64823
1588 67008 1
1588 10350 1
19457 1588 1
46921 62261 32341
79207 1588 1
17106 1588 1
70923 46401 37405
19912 52502 55387
70875 47608 50939...

output:

159996

result:

ok single line: '159996'

Test #102:

score: 0
Accepted
time: 2504ms
memory: 108836kb

input:

79998 160000
51215 31702 40384
72941 6680 35684
34444 58894 34935
32883 40132 40487
56457 74285 37275
25054 29672 1
5668 77684 39244
10410 4082 31379
20850 36661 33559
55492 30572 36833
34311 79579 42195
58218 39451 1
60273 3813 37473
25923 27136 47325
29422 16625 1
73771 7467 1
5323 32654 1
55320 2...

output:

79998

result:

ok single line: '79998'

Test #103:

score: 0
Accepted
time: 2543ms
memory: 104776kb

input:

79998 160000
42885 77262 1
26137 69653 32975
52030 74099 1
45478 50920 30276
65447 79995 1
1859 26514 1
52653 4073 29242
56975 12565 1
73909 13162 1
10755 14534 1
32874 26117 29603
5284 10633 1
25305 59291 1
54743 6976 39183
2157 25332 1
51140 37664 1
309 73212 1
63722 12521 33043
63427 7193 42397
5...

output:

108556

result:

ok single line: '108556'

Test #104:

score: 0
Accepted
time: 2532ms
memory: 107396kb

input:

79998 160000
29143 28120 1
9335 71863 1
75488 30932 29985
17466 14353 31733
22112 8026 30686
5024 22930 26888
17498 3192 29416
43955 24492 34340
57145 11894 1
63560 77469 29900
44944 13746 1
38595 57104 32056
20550 75493 1
26705 35921 1
3848 13758 1
49086 29127 51776
18226 59798 1
52640 60339 1
1946...

output:

88792

result:

ok single line: '88792'

Subtask #8:

score: 4
Accepted

Test #105:

score: 4
Accepted
time: 2835ms
memory: 322960kb

input:

500000 2000000
492952 221541 267388
189147 466806 1
176713 26739 184225
184178 191476 193886
268077 21780 170551
226184 221541 302897
9942 461890 1
221541 343066 171790
495977 267797 176982
213497 330126 205211
128338 411248 1
283722 405246 217711
18538 208366 1
164175 376442 254213
29263 221541 171...

output:

499999

result:

ok single line: '499999'

Test #106:

score: 0
Accepted
time: 2829ms
memory: 320532kb

input:

499999 2000000
338233 340347 226535
38717 379987 168389
336194 116029 1
177994 341315 1
324318 325023 189015
407991 59970 1
363275 468224 1
20980 497440 167304
173157 482862 194272
268329 191991 167875
493110 59848 176331
167640 301032 1
38980 608 1
451792 351819 1
466507 16056 313310
159434 426922 ...

output:

499998

result:

ok single line: '499998'

Test #107:

score: 0
Accepted
time: 2834ms
memory: 292912kb

input:

499999 2000000
225504 367124 184692
13152 368884 1
246115 310825 1
85546 260802 1
36120 263251 1
347061 457515 179247
391512 418943 209628
488000 251230 202554
342387 451505 218204
250597 6360 1
314794 356575 167579
379921 169405 175694
238333 100765 213326
23010 256301 1
138786 206212 195538
119086...

output:

666664

result:

ok single line: '666664'

Test #108:

score: 0
Accepted
time: 2772ms
memory: 285748kb

input:

499998 2000000
239843 21834 170623
83053 349534 191770
82825 125117 173513
250882 82203 1
84947 381078 166941
22652 453627 182123
335543 360105 177097
80826 287621 170686
199733 323380 189528
158984 68066 181722
35365 34669 1
21279 239681 179131
219384 62879 170013
2795 18867 169707
126894 379453 22...

output:

667017

result:

ok single line: '667017'

Test #109:

score: 0
Accepted
time: 2741ms
memory: 279084kb

input:

499998 2000000
355742 293959 1
136181 26342 1
218741 137151 176534
404921 174940 167299
469296 27392 167588
107859 266624 1
244790 166337 184474
189980 367073 1
157285 29642 189173
172758 406073 1
491913 225316 168779
294380 307097 170056
130008 50345 170049
154969 497856 166717
290947 132729 169680...

output:

767066

result:

ok single line: '767066'

Test #110:

score: 0
Accepted
time: 2971ms
memory: 255100kb

input:

500000 2000000
476350 51962 1
476350 292722 1
294805 128846 449372
476350 423345 1
174567 270229 300541
476350 349849 1
120425 488728 235975
419354 55151 169452
476350 17712 1
467841 387986 291040
378472 34286 435949
397453 133063 264757
476350 146174 1
67353 363976 275957
196278 467016 343330
42663...

output:

999996

result:

ok single line: '999996'

Test #111:

score: 0
Accepted
time: 2751ms
memory: 321204kb

input:

499998 2000000
366610 387449 1
374528 86585 1
488325 386540 186356
477280 490684 171522
348324 425830 178981
96980 287110 181522
261528 417619 282357
139407 292432 195815
455017 373830 193821
218772 308990 227996
478845 171275 1
483395 134664 1
97023 120267 168469
5305 177167 169835
68601 332163 202...

output:

500004

result:

ok single line: '500004'

Test #112:

score: 0
Accepted
time: 2770ms
memory: 297100kb

input:

499998 2000000
331665 475012 1
121152 81914 176809
496682 420400 195245
155426 411058 168700
35401 302515 1
225443 370393 1
296555 22177 172708
337088 40800 166685
184844 171421 183185
197144 289143 179437
185993 368 212093
12939 192391 1
200685 376931 1
187169 394076 1
412288 381560 178914
445940 1...

output:

678343

result:

ok single line: '678343'

Test #113:

score: 0
Accepted
time: 2793ms
memory: 314072kb

input:

499998 2000000
319770 442556 1
213924 152866 1
2496 220932 1
437667 82087 177822
457316 266598 282010
239438 454138 175650
252742 72788 1
128488 358061 170500
311235 86405 1
21931 428775 1
333079 442421 238809
140368 456692 264623
85342 498107 229485
371864 380837 179159
319641 441750 172196
11371 4...

output:

555738

result:

ok single line: '555738'

Test #114:

score: 0
Accepted
time: 2763ms
memory: 280852kb

input:

499998 2000000
219926 205092 1
205001 189575 180932
262831 159394 170969
16230 32730 185535
486101 491141 1
69290 486917 172380
188392 125635 167512
183179 50494 167940
390213 10114 185124
51935 210969 168058
37203 325999 177597
165891 391917 167084
469411 62267 174273
171686 6617 198217
29770 91370...

output:

666662

result:

ok single line: '666662'

Test #115:

score: 0
Accepted
time: 2737ms
memory: 291756kb

input:

499995 2000000
184364 177119 1
396742 248057 172628
34398 223566 167004
313764 382786 197485
20867 481289 166931
1599 357588 1
352987 447229 227058
32679 234774 183814
300469 441974 175154
346072 388083 169493
76799 436148 166706
417637 97043 219697
305219 418013 167159
243066 349589 182332
290242 1...

output:

666661

result:

ok single line: '666661'

Test #116:

score: 0
Accepted
time: 2765ms
memory: 287432kb

input:

499989 2000000
467454 448035 249923
206609 192057 249733
486230 447304 249865
262080 104809 249816
360622 267254 249260
73644 380935 1
81733 362647 249458
135629 497166 249719
276985 226667 249858
406381 61291 249775
54689 335340 249427
234880 224555 249794
493610 241933 249411
196987 103975 249297
...

output:

749980

result:

ok single line: '749980'

Test #117:

score: 0
Accepted
time: 2847ms
memory: 268560kb

input:

499998 583330
331941 313413 1
126896 450668 1
275108 498705 1
29551 121348 1
223222 31715 1
16737 163105 1
249144 303337 1
384796 378911 1
435151 496236 171031
185847 2884 1
127968 185797 1
496236 144622 174060
347236 427483 1
126586 377614 1
363507 215250 1
128974 496236 173901
57104 206578 1
13630...

output:

749994

result:

ok single line: '749994'

Test #118:

score: 0
Accepted
time: 2873ms
memory: 267756kb

input:

499998 583330
489471 5305 1
301631 137753 1
15121 345823 1
58881 219758 1
385618 231337 1
453888 306443 1
251827 452251 1
369842 56393 1
274072 269059 1
56974 438928 166960
13598 486999 1
159168 165331 1
85282 228891 1
499947 79120 1
75094 473388 1
398744 83992 1
466430 343501 1
486102 293076 1
1711...

output:

749994

result:

ok single line: '749994'

Extra Test:

score: 0
Extra Test Passed