QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#56444#2556. Yet Another Interval Graph Problemmendicillin2#AC ✓150ms3876kbC++171.1kb2022-10-19 16:36:522022-10-19 16:36:53

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-19 16:36:53]
  • 评测
  • 测评结果:AC
  • 用时:150ms
  • 内存:3876kb
  • [2022-10-19 16:36:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	int N, K;
	cin >> N >> K;
	vector<tuple<int, int, ll>> stuff(N);
	ll total = 0;
	vector<int> vals;
	for (auto& [r, l, w] : stuff) {
		cin >> l >> r >> w;
		vals.push_back(l);
		vals.push_back(r);
		total += w;
	}
	vals.push_back(0);
	sort(vals.begin(), vals.end());
	vals.erase(unique(vals.begin(), vals.end()), vals.end());
	auto lookup = [&](int x) -> int {
		return int(lower_bound(vals.begin(), vals.end(), x) - vals.begin());
	};
	for (auto& [r, l, w] : stuff) {
		r = lookup(r);
		l = lookup(l);
	}
	sort(stuff.begin(), stuff.end());

	int X = int(vals.size());
	vector<ll> dp(X);
	for (int x = 0; x < X; x++) {
		priority_queue<ll, vector<ll>, greater<ll>> pq;
		ll s = 0;
		for (auto [r, l, w] : stuff) {
			if (l > x) {
				pq.push(w);
				s += w;
				while (int(pq.size()) > K) {
					s -= pq.top();
					pq.pop();
				}
				dp[r] = max(dp[r], s + dp[x]);
			}
		}
	}
	ll max_left = *max_element(dp.begin(), dp.end());
	ll ans = total - max_left;
	cout << ans << '\n';

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

3

result:

ok single line: '3'

Test #2:

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

input:

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

output:

12

result:

ok single line: '12'

Test #3:

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

input:

1 1
260947663 693934985 986106006

output:

0

result:

ok single line: '0'

Test #4:

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

input:

2 2
148610427 148610427 611594176
148610427 148610427 241979785

output:

0

result:

ok single line: '0'

Test #5:

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

input:

2 2
189944467 208945642 113891402
208945642 235053342 250664551

output:

0

result:

ok single line: '0'

Test #6:

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

input:

2 2
259102823 862504466 73871288
91533165 259102823 447104717

output:

0

result:

ok single line: '0'

Test #7:

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

input:

2 2
634621570 811155007 87507743
299710238 563644023 98163867

output:

0

result:

ok single line: '0'

Test #8:

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

input:

13 5
385168347 385168347 99054846
385168347 385168347 350748474
385168347 385168347 354902398
385168347 385168347 585042031
385168347 385168347 292548257
385168347 385168347 440215041
385168347 385168347 672336022
385168347 385168347 47484008
385168347 385168347 169165503
385168347 385168347 7956210...

output:

1929854426

result:

ok single line: '1929854426'

Test #9:

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

input:

13 6
249108165 750799499 699592153
249108165 457151813 987869795
134537888 782870665 390805464
134537888 782870665 649518079
204359052 634307327 182450369
204359052 774773106 730624930
249108165 774773106 537210767
204359052 774773106 97138905
204359052 457151813 416638849
134537888 524514128 250590...

output:

1237015857

result:

ok single line: '1237015857'

Test #10:

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

input:

13 7
465368572 465924358 199562084
608564649 997082675 730929009
674709819 678581286 182758027
836643137 882107460 644654785
486136406 758292265 676143876
201512809 479098771 863674394
47616205 381197381 378671320
394857231 595748338 113052048
212725647 465368572 82608327
196452515 409999283 8763323...

output:

1099952673

result:

ok single line: '1099952673'

Test #11:

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

input:

13 2
31872098 871680392 682839350
61764730 487476526 831566242
381374440 997221351 669699198
107368862 640403153 740367257
569214208 652115395 148284098
519532336 743844154 95873458
118903321 512516605 142755369
419658872 669010905 189660758
199540065 249254316 625038715
181930274 228478402 51457966...

output:

3609049933

result:

ok single line: '3609049933'

Test #12:

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

input:

14 5
728352335 728352335 381359028
728352335 728352335 112308217
728352335 728352335 674696127
728352335 728352335 807714141
728352335 728352335 446795815
728352335 728352335 734255090
728352335 728352335 587451095
728352335 728352335 269358391
728352335 728352335 39475712
728352335 728352335 810785...

output:

2424971387

result:

ok single line: '2424971387'

Test #13:

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

input:

14 12
191793304 552864388 80949254
104805491 219644066 69701295
186898587 431239708 24064180
186898587 655934651 814445303
431239708 459349784 928677053
178946842 552864388 859560577
328428262 459349784 654624260
104805491 552864388 950062504
219644066 552864388 250581246
104805491 191793304 2348381...

output:

50607767

result:

ok single line: '50607767'

Test #14:

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

input:

14 14
300455461 658411147 118564055
74775444 249650757 803408069
664445103 893656382 599127386
249650757 281129734 530905142
58928870 615333424 353022736
642734658 660816046 173630646
4495104 715536786 916711506
170445688 656301801 252422382
292382181 656301801 895698233
74065627 479191864 293882251...

output:

0

result:

ok single line: '0'

Test #15:

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

input:

14 8
432046489 978881069 231142550
497322386 878782752 362048483
256198933 792937733 372555775
66506431 895129946 809601646
298840475 627033669 515057457
99457507 609186096 816771967
361334042 978881069 853460916
114590942 448110575 935917705
13145092 508015426 651654
90350442 227603751 34457268
292...

output:

1215869240

result:

ok single line: '1215869240'

Test #16:

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

input:

15 7
71536323 71536323 663663210
71536323 71536323 168835257
71536323 71536323 554298368
71536323 71536323 885162058
71536323 71536323 451300269
71536323 71536323 583584739
71536323 71536323 912631577
71536323 71536323 786200071
71536323 71536323 764561728
71536323 71536323 956470730
71536323 715363...

output:

2670135491

result:

ok single line: '2670135491'

Test #17:

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

input:

15 10
389002390 832393214 312563251
313520949 389002390 591724283
187656255 313520949 657322896
313520949 632787109 534662126
75456701 832063493 410062522
187656255 281053094 843272031
75456701 313520949 772037754
286247352 389002390 362794615
281053094 758595444 674458236
832393214 832393214 738615...

output:

921225063

result:

ok single line: '921225063'

Test #18:

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

input:

15 14
502982426 695256104 37566026
360811734 970630492 580919834
12460198 468757302 720529449
47607915 523380702 827220907
239024704 559272374 175125789
12460198 78664236 188619602
605867309 680213266 454751691
525329146 911823294 686760012
4261798 468757302 443946923
360811734 925969063 151623658
5...

output:

37566026

result:

ok single line: '37566026'

Test #19:

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

input:

15 8
98164859 808676227 779445750
128386421 716816201 597563428
234209607 784220068 485477760
40281846 145198031 878836035
30897339 313983968 176798112
37301494 462024528 537670476
249351686 446325020 709390656
797601962 856372121 536950461
110181370 781175898 376264592
254323552 576269929 849302167...

output:

1853900270

result:

ok single line: '1853900270'

Test #20:

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

input:

16 6
414720311 414720311 945967393
414720311 414720311 930395001
414720311 414720311 874092097
414720311 414720311 962609975
414720311 414720311 605547827
414720311 414720311 22848980
414720311 414720311 387555163
414720311 414720311 153298646
414720311 414720311 339904640
414720311 414720311 682119...

output:

4190876180

result:

ok single line: '4190876180'

Test #21:

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

input:

16 3
8192334 296138897 693920352
296138897 940726987 968523078
298351952 298351952 585548907
298351952 298351952 404622054
298351952 940726987 596480694
8192334 46107911 972207678
46107911 102756404 184418543
73780914 164854509 70494022
46107911 298351952 508400633
594885466 940726987 58109036
81923...

output:

2562185596

result:

ok single line: '2562185596'

Test #22:

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

input:

16 12
275641614 801841335 811343806
95577059 866885529 63464303
394724161 626550634 987155703
429903353 880742943 123536672
85500274 511098550 997228841
416685349 663054530 763417069
728990898 729020007 992791877
17966150 626550634 826130345
728990898 811529667 697228317
191798932 882247362 41943047...

output:

690675139

result:

ok single line: '690675139'

Test #23:

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

input:

16 15
207378409 565152608 327748949
130338029 545690944 978302564
35248203 682729898 333558529
211875096 842599418 93294615
85063237 966649821 133506062
490343758 827886043 258568985
243659596 492931571 565320396
158053532 655699310 578174704
74296171 863518101 161942938
278000331 424880475 51892287...

output:

93294615

result:

ok single line: '93294615'

Test #24:

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

input:

15 8
311276485 886531075 542687345
303889791 886531075 231384714
320479222 886531075 468740692
721363813 886531075 77232377
228450314 886531075 827150033
527057547 886531075 116793316
311276485 886531075 785494700
273376721 886531075 232872222
311276485 886531075 275418603
724304477 886531075 514598...

output:

1486331062

result:

ok single line: '1486331062'

Test #25:

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

input:

15 2
741431866 959250144 688474833
826599694 959250144 589285705
3084690 652474523 131543181
3084690 818625976 252986613
667409877 959250144 294214085
741431866 959250144 333822660
789305564 959250144 307175183
652474523 959250144 178282282
689642919 959250144 640147543
3084690 826599694 393036587
9...

output:

3977226216

result:

ok single line: '3977226216'

Test #26:

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

input:

15 10
281053094 834779585 362794615
75456701 657322896 674458236
832063493 834779585 73861509
591724283 834779585 125024719
354953290 834779585 706013306
75456701 286247352 46980969
75456701 313520949 646003564
75456701 281053094 546712737
75456701 354953290 667713302
75456701 632787109 109150131
31...

output:

408707615

result:

ok single line: '408707615'

Test #27:

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

input:

15 4
141497923 548025160 785806426
141497923 527660509 720655899
141497923 771371793 828385845
141497923 843779781 99422560
141497923 352758161 38982198
141497923 155346807 243766753
141497923 828257135 241640981
141497923 921180816 402088000
141497923 353850883 834255872
141497923 826704874 6473136...

output:

3328733790

result:

ok single line: '3328733790'

Test #28:

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

input:

16 16
66022690 978150230 354759825
602783405 978150230 563217474
212301933 978150230 214922773
628180783 978150230 273946374
659163903 978150230 527604785
817565058 978150230 760025478
602783405 978150230 791570876
823067206 978150230 411882374
823067206 978150230 92521476
640571236 978150230 952104...

output:

0

result:

ok single line: '0'

Test #29:

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

input:

16 12
590274613 889380200 452952399
327794203 889380200 251229138
5330990 744933187 929170485
5330990 314614327 377216688
409453342 889380200 536747299
5330990 54904376 32440775
361401916 889380200 321742341
5330990 70074176 974876069
327794203 889380200 437471787
361401916 889380200 989756541
54904...

output:

756715795

result:

ok single line: '756715795'

Test #30:

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

input:

16 3
585548907 968523078 744856771
46107911 968523078 333993896
8192334 606692761 424145644
8192334 398644849 805825024
8192334 693920352 790872411
8192334 542551430 496441740
298351952 968523078 277150098
164854509 968523078 963199595
8192334 298351952 834534890
298351952 968523078 267503821
819233...

output:

6399014605

result:

ok single line: '6399014605'

Test #31:

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

input:

16 15
725916 57874638 27947927
725916 324502093 574757183
725916 248536551 239572123
725916 652533338 100510176
714583077 995185465 11406295
725916 372473799 491363244
725916 925611281 139579909
725916 248536551 858441046
725916 810672756 751074163
725916 129902704 747194470
725916 281408124 8552275...

output:

11406295

result:

ok single line: '11406295'

Test #32:

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

input:

14 1
623816097 623816097 68434400
623816097 623816097 725559682
623816097 623816097 678758318
623816097 623816097 368499632
623816097 623816097 495567409
623816097 623816097 236794280
623816097 623816097 779885584
623816097 623816097 879061467
623816097 623816097 537101862
623816097 623816097 465992...

output:

5864098008

result:

ok single line: '5864098008'

Test #33:

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

input:

14 1
474097486 930251201 788591065
2688701 471061191 845510022
2688701 203686122 275418775
203686122 601081080 31535815
474097486 474097486 228315825
161901890 474097486 85031827
203686122 601081080 337856340
471061191 601081080 604276423
161332531 471061191 357335089
262608550 474097486 82141704
26...

output:

3746923312

result:

ok single line: '3746923312'

Test #34:

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

input:

14 1
494186620 531108277 961242307
620452125 623567580 364091773
23975216 357841107 512604788
59502148 793676488 729004547
293504000 748896401 598615542
398747973 967374174 642479347
31019655 476793418 584205112
376644841 543109385 320093318
874414082 884558783 925710684
327711462 354634260 92343656...

output:

4831774383

result:

ok single line: '4831774383'

Test #35:

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

input:

14 1
75174224 119784548 640235191
56979455 517584689 581193450
497947002 769774984 246540162
466114327 730965896 881923182
172607550 997207262 13580762
5487679 223191218 16441814
514455732 804556479 420528181
791494 889547290 132020407
57805993 72102775 395810666
24721884 570779130 309337420
2039556...

output:

4024725163

result:

ok single line: '4024725163'

Test #36:

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

input:

15 1
58620784 58620784 849177067
58620784 58620784 399820121
58620784 58620784 321591112
58620784 58620784 590469955
58620784 58620784 778815132
58620784 58620784 110225002
58620784 58620784 72173525
58620784 58620784 248944784
58620784 58620784 264448423
58620784 58620784 179086970
58620784 5862078...

output:

5517385453

result:

ok single line: '5517385453'

Test #37:

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

input:

15 1
120499167 737960258 289831217
188517125 861916695 432401208
314969249 489257625 134251335
314969249 479688236 934063647
737960258 915091291 728675035
479688236 915091291 112232840
188517125 489257625 381850362
737960258 737960258 600105949
479688236 915091291 755144458
314969249 811412746 19830...

output:

5223006777

result:

ok single line: '5223006777'

Test #38:

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

input:

15 1
266400374 703528681 36393824
594193361 976071354 322705157
154888493 979288360 146631352
322216381 884826148 118504871
105920740 250676363 218705399
46771526 407348616 919508420
65145206 796279271 881762405
105920740 913855482 438273012
250676363 886197297 601198860
413043368 866845047 44053716...

output:

4626188352

result:

ok single line: '4626188352'

Test #39:

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

input:

15 1
602765744 659388029 446747353
886778 924974969 66140536
63864811 894375873 887218253
151320987 886529554 545427866
232494922 677832640 227099350
464766957 668586498 66843806
486612493 881877055 922418153
465012711 690832285 819906688
165877800 755783659 60853420
24794931 997302251 802237488
268...

output:

7200638172

result:

ok single line: '7200638172'

Test #40:

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

input:

16 1
933616960 933616960 70111222
933616960 933616960 779113265
933616960 933616960 259391202
933616960 933616960 252631766
933616960 933616960 207287046
933616960 933616960 278623020
933616960 933616960 219237273
933616960 933616960 764052293
933616960 933616960 991794984
933616960 933616960 892181...

output:

6225784753

result:

ok single line: '6225784753'

Test #41:

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

input:

16 1
651052392 671389169 936295560
280953201 517073052 724325098
942202477 987541587 698116600
280953201 733156640 981815671
280953201 651052392 524001540
280953201 517073052 549499261
213071201 280953201 720811681
280953201 733156640 741159666
517073052 517073052 152953826
213071201 733156640 46420...

output:

7254321392

result:

ok single line: '7254321392'

Test #42:

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

input:

16 1
524883191 962211170 966321148
667341153 858112365 131575437
446096717 525047220 930401020
638356526 964764497 213037899
525047220 724960895 573954041
348268484 667341153 931696276
175922688 648075314 739128210
206072260 570755227 261485409
58976272 175922688 276687037
915307492 915307492 290731...

output:

5658331734

result:

ok single line: '5658331734'

Test #43:

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

input:

16 1
181038948 762840677 253259515
134123759 799291629 846054918
10628886 29338960 937961751
39703970 878299059 913965255
358211613 365812014 290874835
55652279 677909046 266988902
166567935 907544528 424308126
502938667 597999829 67601480
331641871 448929982 20863470
41853618 433958813 149913364
21...

output:

3646373294

result:

ok single line: '3646373294'

Test #44:

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

input:

14 11
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
596868476 596868476 1
59686847...

output:

3

result:

ok single line: '3'

Test #45:

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

input:

14 8
299755849 335236157 1
549362417 916670570 1
335236157 947600061 1
249715205 598937209 1
249715205 598937209 1
549362417 549362417 1
335236157 534977292 1
534977292 598937209 1
534977292 916670570 1
249715205 387109674 1
249715205 947600061 1
534977292 947600061 1
534977292 598937209 1
534977292...

output:

5

result:

ok single line: '5'

Test #46:

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

input:

14 14
147077273 719770043 1
249885468 453139504 1
289057660 904925065 1
468494784 501341613 1
470093219 615748838 1
95634637 468494784 1
196514909 441683724 1
126680367 514163748 1
93396333 851469378 1
93396333 758192196 1
679314973 780706964 1
273889708 464038211 1
472588578 861023617 1
275820318 6...

output:

0

result:

ok single line: '0'

Test #47:

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

input:

14 9
32194836 867511040 1
24929426 600929236 1
645179903 761449596 1
272098490 403964909 1
162554009 761001282 1
86735752 758283025 1
31569697 888406642 1
227882500 787874983 1
139365753 600929236 1
661812069 779073277 1
53830370 91705473 1
22000363 80904211 1
166028140 221764108 1
239136240 6436796...

output:

4

result:

ok single line: '4'

Test #48:

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

input:

15 6
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168 645085168 1
645085168...

output:

9

result:

ok single line: '9'

Test #49:

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

input:

15 8
823807077 975971097 1
113623115 975950321 1
292870203 361429461 1
113623115 823807077 1
481887392 975950321 1
823807077 823807077 1
292870203 361429461 1
481887392 823807077 1
292870203 975971097 1
357760883 975950321 1
481887392 571068238 1
361429461 823807077 1
571068238 823807077 1
357760883...

output:

7

result:

ok single line: '7'

Test #50:

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

input:

15 12
296964699 369458229 1
369458229 735814213 1
42306146 588034934 1
770769000 799591226 1
565667645 627319603 1
565667645 791917364 1
369458229 779718230 1
47755733 195318995 1
55515122 408914018 1
225730264 887019018 1
80253904 839300530 1
33370637 245227584 1
291545577 779718230 1
166233725 839...

output:

3

result:

ok single line: '3'

Test #51:

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

input:

15 8
441583661 986820752 1
436112212 678812654 1
524453456 545274190 1
573197260 727196768 1
154284929 171432513 1
476133322 527409709 1
133104793 505301478 1
21867853 485912527 1
723426651 799823448 1
273454665 694167857 1
277391795 513601293 1
897650066 917364514 1
326281300 384499920 1
673838373 ...

output:

4

result:

ok single line: '4'

Test #52:

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

input:

16 6
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156 988269156 1
988269156...

output:

10

result:

ok single line: '10'

Test #53:

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

input:

16 3
416964902 466102368 1
269145906 747197080 1
466102368 809243127 1
416964902 466102368 1
833418586 833418586 1
709333286 833418586 1
269145906 809243127 1
132477014 132477014 1
328412093 747197080 1
328412093 747197080 1
132477014 833418586 1
809243127 809243127 1
809243127 827626917 1
269145906...

output:

9

result:

ok single line: '9'

Test #54:

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

input:

16 12
174295242 413057436 1
123197795 628189289 1
39094163 196553473 1
586739568 686216852 1
78636381 911693355 1
174295242 208267547 1
405495253 413057436 1
521801925 970665926 1
326961516 833110805 1
300546802 805125059 1
549617140 916602876 1
205327600 851274679 1
293703057 730381664 1
244300337 ...

output:

4

result:

ok single line: '4'

Test #55:

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

input:

16 15
119090683 808687459 1
667152027 883164468 1
60945147 342057982 1
372980777 774456899 1
229207313 817030099 1
607771143 815307550 1
370044026 955887682 1
198383231 439460723 1
82743844 444409806 1
126886602 713587926 1
143187233 902942782 1
695911023 783135560 1
218042838 735506515 1
430463187 ...

output:

1

result:

ok single line: '1'

Test #56:

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

input:

15 7
845782549 992241211 1
879060576 992241211 1
955382199 992241211 1
656922228 992241211 1
285155200 992241211 1
142639807 992241211 1
397582855 992241211 1
955382199 992241211 1
283239044 992241211 1
285155200 992241211 1
955382199 992241211 1
898874014 992241211 1
346108700 992241211 1
136042555...

output:

8

result:

ok single line: '8'

Test #57:

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

input:

15 2
558159059 866753481 1
522651681 866753481 1
522651681 866753481 1
514335259 866753481 1
94553606 866753481 1
388431731 866753481 1
62028640 232503402 1
62028640 75658301 1
62028640 94553606 1
522651681 866753481 1
566258181 866753481 1
62028640 842530763 1
62028640 797975230 1
94553606 86675348...

output:

11

result:

ok single line: '11'

Test #58:

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

input:

15 8
11715276 794271156 1
813694606 975971097 1
11715276 250363341 1
11715276 813694606 1
11715276 571068238 1
813694606 975971097 1
11715276 571068238 1
11715276 975950321 1
481887392 975971097 1
11715276 361429461 1
11715276 250363341 1
11715276 85794810 1
481887392 975971097 1
11715276 234555532 ...

output:

4

result:

ok single line: '4'

Test #59:

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

input:

15 2
362432078 387471233 1
362432078 367115745 1
362432078 906953652 1
362432078 604561661 1
362432078 510376539 1
362432078 770782808 1
362432078 373389922 1
362432078 510376539 1
362432078 671370449 1
362432078 367115745 1
362432078 851531307 1
362432078 367115745 1
362432078 636155065 1
362432078...

output:

13

result:

ok single line: '13'

Test #60:

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

input:

16 16
160749046 957499484 1
333445586 957499484 1
43170959 957499484 1
289659654 957499484 1
284529152 957499484 1
388935887 957499484 1
220087724 957499484 1
220087724 957499484 1
281585584 957499484 1
192569595 957499484 1
192569595 957499484 1
192569595 957499484 1
805027435 957499484 1
284529152...

output:

0

result:

ok single line: '0'

Test #61:

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

input:

16 12
462638080 976852879 1
49365526 514922542 1
928335098 976852879 1
928335098 976852879 1
815347059 976852879 1
348738802 976852879 1
604090507 976852879 1
744335736 976852879 1
118290868 976852879 1
49365526 815347059 1
348738802 976852879 1
347945827 976852879 1
606375751 976852879 1
49365526 8...

output:

4

result:

ok single line: '4'

Test #62:

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

input:

16 3
14020822 771060062 1
771060062 966670910 1
14020822 401831692 1
14020822 771060062 1
328412093 966670910 1
14020822 809243127 1
14020822 190493401 1
827626917 966670910 1
833418586 966670910 1
14020822 833418586 1
14020822 827626917 1
401831692 966670910 1
14020822 466102368 1
673028871 9666709...

output:

10

result:

ok single line: '10'

Test #63:

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

input:

16 15
3333426 825886901 1
3333426 357346389 1
3333426 647213199 1
3333426 647213199 1
3333426 599596461 1
3333426 76435880 1
3333426 647213199 1
3333426 669445905 1
3333426 910525352 1
3333426 825886901 1
3333426 143455197 1
3333426 102245782 1
3333426 825886901 1
292805796 971828500 1
3333426 82588...

output:

1

result:

ok single line: '1'

Test #64:

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

input:

246 113
547075991 547075991 97098787
547075991 547075991 650529506
547075991 547075991 94194662
547075991 547075991 300831799
547075991 547075991 210979063
547075991 547075991 669838023
547075991 547075991 818481001
547075991 547075991 954968998
547075991 547075991 655551346
547075991 547075991 4500...

output:

39489977894

result:

ok single line: '39489977894'

Test #65:

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

input:

246 60
153793909 153793909 148551428
362774883 631317546 949355670
176931975 227974291 472505046
362774883 782234006 71305112
524014446 651560334 922086601
362774883 631317546 289572511
362774883 958590389 126402322
153793909 631317546 111150218
631317546 782234006 422718937
176931975 524014446 8765...

output:

58020953862

result:

ok single line: '58020953862'

Test #66:

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

input:

246 80
439684289 738059484 71011673
528900314 876412261 682333532
257858159 866154084 855772780
919959736 931610307 674626599
149635741 383115153 837074928
178722363 609534742 842673154
383115153 436928798 325306823
425759893 795888849 824228202
28123497 690263440 270585514
159260014 784348280 89083...

output:

51464594120

result:

ok single line: '51464594120'

Test #67:

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

input:

246 150
187741878 209318652 252817976
254729609 261465597 321995895
859566098 912919263 245463881
340090131 955974216 897861679
852234825 959408277 986887086
203319631 759485433 356273490
172470951 743827994 391923701
63141049 81912952 582627905
299045570 478377025 175578482
373197584 408164919 5625...

output:

19407849025

result:

ok single line: '19407849025'

Test #68:

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

input:

247 245
890259979 890259979 379402969
890259979 890259979 707056545
890259979 890259979 268764199
890259979 890259979 818471204
890259979 890259979 70259326
890259979 890259979 668910776
890259979 890259979 588371883
890259979 890259979 617034870
890259979 890259979 85670066
890259979 890259979 3048...

output:

9070156

result:

ok single line: '9070156'

Test #69:

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

input:

247 170
792234988 803768688 380165425
353060816 353060816 326154466
316735414 473263644 250987954
648454096 803768688 236232336
286506699 648454096 963280582
473263644 964365549 418508158
683678245 803768688 243815815
683678245 964365549 669106521
124445118 316735414 551628630
473263644 792234988 42...

output:

10876461600

result:

ok single line: '10876461600'

Test #70:

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

input:

247 22
127014395 583778408 619314872
540247245 693032536 212815772
171954917 637720344 558629357
365307415 706772385 38828284
74025026 215480628 498815582
52055763 566934469 563571663
273053686 645088280 741045075
149338443 567459135 720228254
436776405 662223097 646198453
667081877 796055608 410714...

output:

86351312781

result:

ok single line: '86351312781'

Test #71:

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

input:

247 143
408668320 739992735 191683444
146278640 706342389 449446681
23455638 190142893 218148545
106112342 724326908 134230427
50077687 831906446 853881431
53949119 457140390 198782900
552306878 789415379 812296790
349030203 950919576 466630620
106178272 376370386 402945842
319183749 645097099 35998...

output:

20112106224

result:

ok single line: '20112106224'

Test #72:

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

input:

248 183
938476671 938476671 956674447
938476671 938476671 323392097
938476671 938476671 293590632
938476671 938476671 895919121
938476671 938476671 369731076
938476671 938476671 108175017
938476671 938476671 208519661
938476671 938476671 838909253
938476671 938476671 955980274
938476671 938476671 61...

output:

11731257090

result:

ok single line: '11731257090'

Test #73:

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

input:

248 80
234222361 390063624 761522526
291721285 539729789 553210157
291721285 885782048 179213966
444710059 488060907 811224967
390063624 444710059 149698754
211271494 885782048 992154204
390063624 885782048 361229309
234222361 885782048 376805928
291721285 291721285 240346835
234222361 390063624 404...

output:

55015010568

result:

ok single line: '55015010568'

Test #74:

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

input:

248 9
709421074 873222687 727426584
189817836 527978062 448330717
456259638 713883479 966518638
441461502 868982255 108062673
76324842 280031282 455523533
132760604 946860180 284470172
751989507 903871807 596974815
1565484 859797788 466485201
538853496 959745851 872068287
526200990 840881617 2255597...

output:

96323934394

result:

ok single line: '96323934394'

Test #75:

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

input:

248 180
294270556 611377483 130548911
34598659 525002301 871864763
768444153 881726081 190833208
110516356 253519422 960533767
240762624 714300592 425908480
146767922 263085563 481483797
417895183 728177677 232669879
454816078 633572087 645600632
268752748 919738539 335345905
550256806 862815505 717...

output:

10238022571

result:

ok single line: '10238022571'

Test #76:

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

input:

249 39
576627955 576627955 944011333
576627955 576627955 379919137
576627955 576627955 468160170
576627955 576627955 973367038
576627955 576627955 229011338
576627955 576627955 252471961
576627955 576627955 828667438
576627955 576627955 355750932
576627955 576627955 826290483
576627955 576627955 415...

output:

93496151845

result:

ok single line: '93496151845'

Test #77:

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

input:

249 225
70499488 928725534 142879628
410351203 472891910 930008953
472891910 685756298 107439978
473852828 928725534 826409087
266413369 792918555 485860031
70499488 410351203 121089851
70499488 360714834 773610098
70499488 360714834 789538039
792918555 811491203 664223824
360714834 410351203 389068...

output:

1399313508

result:

ok single line: '1399313508'

Test #78:

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

input:

249 163
259184692 812689363 275729784
5899424 180500337 978812958
242825949 581967590 519632110
489553295 639631848 322521254
658340192 706489698 117264188
310196788 550172912 710401385
125063532 208898574 452904554
528734123 753971618 507709445
246866216 298140294 247681225
373640942 863148846 4040...

output:

16319029833

result:

ok single line: '16319029833'

Test #79:

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

input:

249 138
210414484 812961210 69414378
343244334 918754577 704348253
202648187 875393478 163517872
33406186 496444953 51678323
433118188 589120097 292902825
473741804 845424131 618960503
403053484 530503906 653042968
917693745 964459981 529603347
532259746 733973516 267745968
403397631 827530800 51461...

output:

25522126638

result:

ok single line: '25522126638'

Test #80:

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

input:

250 77
965070902 965070902 224977003
965070902 965070902 664810904
965070902 965070902 526935147
965070902 965070902 251505906
965070902 965070902 86220074
965070902 965070902 796494037
965070902 965070902 101651087
965070902 965070902 641348643
965070902 965070902 109399578
965070902 965070902 4092...

output:

60842496169

result:

ok single line: '60842496169'

Test #81:

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

input:

250 6
910820198 975630562 894126566
391082000 910820198 903164178
318167078 975630562 304892542
253051595 975630562 21341964
97093586 97093586 379483515
37974665 97093586 403739591
253051595 910820198 566338255
179739029 179739029 826383416
37974665 391082000 887079569
97093586 910820198 825902007
5...

output:

94435661772

result:

ok single line: '94435661772'

Test #82:

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

input:

250 199
611751826 786682657 91468178
749480617 907955265 922010826
95103864 992034219 715861859
96786964 908808480 709390232
33420867 428763593 161547704
37937526 82319706 451027685
114523189 805228657 904086551
634631917 883575681 725347175
709327797 889463669 71757194
87387822 947718913 231928730
...

output:

5474470173

result:

ok single line: '5474470173'

Test #83:

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

input:

250 222
113084848 285065247 189278862
216804892 805913051 521323597
123466315 905938717 309631892
176651132 808722747 348512590
271863909 477585219 166415385
691442341 809811255 27551290
30203835 447217557 32373970
21340063 602364050 648239695
191255759 392299551 652341284
347788547 683029491 331924...

output:

1124018547

result:

ok single line: '1124018547'

Test #84:

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

input:

248 242
947155885 999213546 990747848
234539954 999213546 248001885
68909810 999213546 926984879
433027085 999213546 382658088
903584952 999213546 852040238
687410107 999213546 782243512
349205252 999213546 421766947
518605592 999213546 274979141
545481116 999213546 387073474
545481116 999213546 545...

output:

85684218

result:

ok single line: '85684218'

Test #85:

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

input:

248 37
311669323 993868410 408455674
60991551 993868410 74864510
957406240 993868410 845884549
738780625 993868410 141573726
835473403 993868410 401573257
7861658 333289065 512040569
660686810 993868410 853147291
7861658 334875504 189650326
249873337 993868410 19203284
881965334 993868410 403146049
...

output:

72255585588

result:

ok single line: '72255585588'

Test #86:

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

input:

248 200
1390648 913464260 921539115
481595229 996169751 238509611
511795556 996169751 527399798
1390648 476210690 519070822
1390648 139729708 207089340
1390648 536060001 795106004
1390648 880919728 198612505
1390648 520573437 3615930
1390648 94387188 518489757
1390648 664160336 100542355
1390648 869...

output:

5159899468

result:

ok single line: '5159899468'

Test #87:

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

input:

248 239
895088 458905921 680991153
895088 641831993 243262285
895088 338186275 263983888
895088 125199562 320044837
895088 125199562 335626461
895088 976432340 317220636
895088 371179502 932917491
895088 173223713 637066382
895088 639111109 188429392
895088 173223713 55361596
895088 667896275 277963...

output:

277711558

result:

ok single line: '277711558'

Test #88:

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

input:

249 76
901408076 996823864 102372390
177059214 996823864 35541486
493143509 996823864 503107529
488808890 996823864 655064567
401612575 996823864 803531769
855574058 996823864 749676116
944851052 996823864 584748692
289747066 996823864 604842899
499104126 996823864 255950843
736723464 996823864 4913...

output:

61068811934

result:

ok single line: '61068811934'

Test #89:

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

input:

249 9
849625426 987664374 908159770
199221963 987664374 411544949
4594401 702500638 528248953
875850664 987664374 831749931
657549980 987664374 988638001
647895286 987664374 487807873
541734825 987664374 82901595
469939325 987664374 353534072
110555961 987664374 712159619
979355545 987664374 6818380...

output:

109112011095

result:

ok single line: '109112011095'

Test #90:

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

input:

249 42
2819511 385658278 195473949
2819511 84307961 581821042
2819511 417379657 14361379
2819511 504772981 83662442
303937748 996706536 951318439
2819511 427754114 121682616
2819511 545052234 677306509
215230974 996706536 602975994
2819511 695800240 421891535
2819511 627312447 752018213
2819511 5919...

output:

69633422158

result:

ok single line: '69633422158'

Test #91:

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

input:

249 227
6406391 395092144 189640321
6406391 378001287 194175818
6406391 100381440 435620757
6406391 715557692 70103
6406391 634363606 525859982
6406391 216337811 331014787
6406391 574036518 898016592
6406391 786094057 511746593
6406391 300060024 778760382
6406391 864059803 340763336
6406391 99773972...

output:

1323971486

result:

ok single line: '1323971486'

Test #92:

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

input:

250 120
353246788 980994189 420907392
884758710 980994189 465923849
21200865 980994189 729956569
831754506 980994189 489705698
254875366 980994189 857389937
153333270 980994189 682441431
283444798 980994189 437716811
260506353 980994189 670423311
293564608 980994189 238854352
778236640 980994189 609...

output:

35486118557

result:

ok single line: '35486118557'

Test #93:

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

input:

250 132
872465838 997961550 712644710
684301 511190122 857827022
667845522 997961550 577192016
684301 85229234 40530641
684301 172717953 961663613
684301 569508862 523233494
143441645 997961550 914943759
778338884 997961550 612389787
580286704 997961550 53426432
875434728 997961550 999669744
3056226...

output:

32909240386

result:

ok single line: '32909240386'

Test #94:

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

input:

250 167
6260814 239982758 40054061
738477573 993260471 257036535
6260814 662384353 139000227
6260814 401417395 177260314
473029294 993260471 931451205
519344474 993260471 920107951
6260814 841197445 769575272
6260814 768818986 106304300
6260814 662584837 242556357
6260814 34029050 279892141
17973384...

output:

13410057608

result:

ok single line: '13410057608'

Test #95:

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

input:

250 159
1092050 429911811 280858911
1092050 430974455 610554819
1092050 580095765 69599029
1092050 63299022 976085044
1092050 547848146 667574058
1092050 812575191 887129468
1092050 802344918 909472291
1092050 93555623 805944187
1092050 535109061 103003
1092050 761425432 601210981
1092050 556356603 ...

output:

17716956863

result:

ok single line: '17716956863'

Test #96:

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

input:

248 1
798307257 798307257 359993686
798307257 798307257 812363141
798307257 798307257 872983330
798307257 798307257 537223276
798307257 798307257 375626816
798307257 798307257 518196362
798307257 798307257 474572280
798307257 798307257 277617903
798307257 798307257 473712578
798307257 798307257 5366...

output:

119894782350

result:

ok single line: '119894782350'

Test #97:

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

input:

248 1
106716204 134413027 820571410
639195985 658024378 685768282
22383466 885531934 273730628
106716204 885531934 67224076
106716204 885531934 984556051
151623368 527066675 495233434
106716204 538526558 54768332
134413027 538526558 885649153
106716204 885531934 467319104
508538911 527066675 2628753...

output:

123443346507

result:

ok single line: '123443346507'

Test #98:

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

input:

248 1
459464034 997962180 761229184
227479654 273550682 80511490
174747895 624745165 534879740
130619474 752848651 703375936
110505930 869151139 645656606
174430647 777916252 351250186
320313925 357598946 932041340
214550801 265733786 381197847
199191480 512169278 290848269
214550801 569697779 88717...

output:

115974717700

result:

ok single line: '115974717700'

Test #99:

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

input:

248 1
712161748 857098296 483281188
635238057 843933145 219483541
840156851 968434599 289113173
233731925 667800790 975105667
79096556 418458947 932773275
294354627 806377423 40986123
446437143 698187074 966903557
51500257 286424379 266246550
547772784 737573545 102689016
604191629 896399185 6902062...

output:

116538147809

result:

ok single line: '116538147809'

Test #100:

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

input:

249 1
233111944 233111944 285960545
233111944 233111944 486623581
233111944 233111944 665559228
233111944 233111944 199385087
233111944 233111944 363907243
233111944 233111944 391627084
233111944 233111944 621636028
233111944 233111944 647501221
233111944 233111944 201059139
233111944 233111944 2497...

output:

121970149470

result:

ok single line: '121970149470'

Test #101:

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

input:

249 1
202663893 202663893 467035753
13852711 204515010 417883660
263027776 744759927 132563188
271909522 744759927 969751908
51319244 202663893 779882557
204515010 271909522 667658639
13852711 271909522 803795058
744759927 977050385 321670167
13852711 271909522 160095769
51319244 204515010 528777752...

output:

120570950601

result:

ok single line: '120570950601'

Test #102:

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

input:

249 1
530074088 646491346 712965538
423805584 782427209 565458576
324887848 571639938 880590535
865571353 933517419 71913324
810570146 961105236 859175195
200382842 392923562 551395283
16496713 398088551 433931313
31171330 399321359 923859936
719360691 853214314 250858319
232634960 991281525 2348525...

output:

109509467071

result:

ok single line: '109509467071'

Test #103:

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

input:

249 1
482591031 950477424 603537513
586394313 630417040 976764951
70174900 703482916 864993520
802114977 843452033 909130125
522920470 617574055 985417847
94722043 124804691 62141126
54891725 743264793 64668427
265325294 308884398 224768111
400928204 401249869 901913628
494669349 658087227 997901531...

output:

112140093460

result:

ok single line: '112140093460'

Test #104:

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

input:

250 1
791357881 791357881 798775363
791357881 791357881 138269412
791357881 791357881 307845195
791357881 791357881 744824622
791357881 791357881 176142409
791357881 791357881 437271206
791357881 791357881 534155807
791357881 791357881 80464929
791357881 791357881 50063538
791357881 791357881 988173...

output:

113493854665

result:

ok single line: '113493854665'

Test #105:

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

input:

250 1
531555466 780895069 103184151
780895069 935560777 202473615
531555466 963941525 128172918
151192560 374694117 28096208
290113341 290113341 189814034
935560777 963941525 520372727
151192560 780895069 205494163
318814550 374694117 857332391
121832866 780895069 135837751
151192560 205368507 97537...

output:

114626749094

result:

ok single line: '114626749094'

Test #106:

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

input:

250 1
256266618 430895252 326029865
118535250 563687218 614131176
7574692 330426895 244679752
27918287 600335600 711027519
108116184 894068489 56008681
432845906 893598879 102519231
727590279 870779611 254977288
282077314 654078599 437187215
753180632 901346436 876422805
139294964 502567982 68596096...

output:

114846406923

result:

ok single line: '114846406923'

Test #107:

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

input:

250 1
326551712 946016786 422346564
733200676 810455411 698309833
642204270 659267579 189695156
214815662 471444425 375956910
65325779 658198845 143978223
329622763 488116519 987927336
13580152 269613480 198328227
231079582 411625445 640598951
536659354 622392781 545008672
174030034 175247730 750871...

output:

119108635627

result:

ok single line: '119108635627'

Test #108:

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

input:

248 135
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992...

output:

113

result:

ok single line: '113'

Test #109:

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

input:

248 40
377400510 615563728 1
533035619 865270129 1
320586735 587946481 1
432205649 615563728 1
320586735 615563728 1
723259390 723259390 1
467410161 587946481 1
467410161 467410161 1
533035619 587946481 1
533035619 615563728 1
377400510 723259390 1
432205649 865270129 1
320586735 377400510 1
3205867...

output:

168

result:

ok single line: '168'

Test #110:

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

input:

248 217
147347540 594161740 1
723258860 877210169 1
425066537 464064708 1
1869932 404268491 1
411187789 594161740 1
610041829 934781812 1
445073195 464263549 1
169499667 523255757 1
154234015 607147611 1
223642273 275350834 1
106759254 754292364 1
607766410 903195689 1
147347540 580630975 1
18977368...

output:

29

result:

ok single line: '29'

Test #111:

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

input:

248 132
600863446 782295425 1
146669218 458212457 1
397983990 419652057 1
500157846 520728081 1
798264822 908579151 1
153194026 968898462 1
53607593 531267646 1
18483145 607528144 1
112337634 148305501 1
559797059 768726343 1
138978763 681841417 1
208922406 269579467 1
70828443 591817987 1
170701560...

output:

92

result:

ok single line: '92'

Test #112:

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

input:

249 237
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176800 150176800 1
150176...

output:

12

result:

ok single line: '12'

Test #113:

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

input:

249 14
292042847 643019016 1
962882026 962882026 1
323907582 643019016 1
292042847 307016972 1
307016972 643019016 1
643019016 854388653 1
291433643 473204311 1
473204311 854388653 1
643019016 962882026 1
47401672 323907582 1
291433643 307016972 1
47401672 643019016 1
47401672 291433643 1
47401672 6...

output:

196

result:

ok single line: '196'

Test #114:

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

input:

249 112
716517587 882696738 1
714895100 731100321 1
226064982 989010633 1
92544639 217940624 1
604508913 818033200 1
309537669 707018865 1
680345118 915337722 1
243114646 574630708 1
271653814 894323272 1
74603516 306560968 1
492627959 631278965 1
493626183 719803821 1
412307910 547660569 1
52059245...

output:

104

result:

ok single line: '104'

Test #115:

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

input:

249 16
440925145 707043718 1
30579655 280262265 1
107985944 505571581 1
671173172 883179717 1
428866612 994467174 1
369145997 671549837 1
148906454 860437854 1
111209484 306773745 1
40442116 925144350 1
40058442 99089982 1
646953430 782696490 1
135724779 310964570 1
279849707 849407599 1
63263374 15...

output:

185

result:

ok single line: '185'

Test #116:

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

input:

250 2
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
538619747 538619747 1
53861974...

output:

248

result:

ok single line: '248'

Test #117:

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

input:

250 226
291210959 753287874 1
520109339 927312035 1
121744182 520109339 1
121744182 841774875 1
226185944 753287874 1
753287874 753287874 1
841774875 895438556 1
226185944 841774875 1
226185944 841774875 1
472779352 841774875 1
226185944 927312035 1
472779352 841774875 1
753287874 927312035 1
121744...

output:

24

result:

ok single line: '24'

Test #118:

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

input:

250 77
26087302 502856272 1
277683794 616668787 1
491155096 944616781 1
482277526 627844455 1
549435869 553407552 1
180196269 728117684 1
336730920 827559515 1
311849419 677370563 1
486189920 711288410 1
528328182 631517597 1
578742314 836605499 1
659053925 795424701 1
197867290 910626578 1
87728823...

output:

129

result:

ok single line: '129'

Test #119:

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

input:

250 146
597625906 908956130 1
144744847 554113366 1
757926045 813926141 1
433908817 557849975 1
390094662 467325946 1
578610319 628578008 1
136638542 138842502 1
407948527 759727687 1
64251192 581908767 1
193401983 374478895 1
429657290 772996157 1
368130742 925699638 1
189831268 646570022 1
2019791...

output:

89

result:

ok single line: '89'

Test #120:

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

input:

248 194
458339816 999440350 1
922127954 999440350 1
489376833 999440350 1
913922647 999440350 1
112752003 999440350 1
342928474 999440350 1
811381275 999440350 1
651360919 999440350 1
858429574 999440350 1
950912986 999440350 1
817275737 999440350 1
206419645 999440350 1
446737677 999440350 1
245403...

output:

54

result:

ok single line: '54'

Test #121:

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

input:

248 237
450543368 997335626 1
768992398 997335626 1
350311760 997335626 1
112561 845687370 1
204324184 997335626 1
51972184 997335626 1
112561 183534839 1
729573523 997335626 1
8165701 997335626 1
427165889 997335626 1
3260809 997335626 1
112561 411570788 1
611333768 997335626 1
177418787 997335626 ...

output:

11

result:

ok single line: '11'

Test #122:

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

input:

248 32
368641 108606428 1
368641 465449465 1
855946479 999005847 1
368641 178720815 1
608556189 999005847 1
368641 857699890 1
368641 180189476 1
368641 339588727 1
368641 869221842 1
368641 669254177 1
368641 148712359 1
987110720 999005847 1
849934835 999005847 1
368641 781947032 1
368641 33388585...

output:

184

result:

ok single line: '184'

Test #123:

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

input:

248 71
14623008 214891064 1
14623008 703970066 1
14623008 703970066 1
14623008 352586677 1
14623008 60076340 1
14623008 309777392 1
14623008 248027644 1
14623008 48369100 1
14623008 896103929 1
14623008 698128510 1
14623008 26412172 1
14623008 841640068 1
14623008 248027644 1
14623008 396445984 1
14...

output:

170

result:

ok single line: '170'

Test #124:

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

input:

249 114
731173843 997297931 1
149251592 997297931 1
706052470 997297931 1
149251592 997297931 1
21237198 997297931 1
732604285 997297931 1
922246295 997297931 1
605698023 997297931 1
755625653 997297931 1
310106453 997297931 1
273225808 997297931 1
857432333 997297931 1
307109903 997297931 1
1229674...

output:

135

result:

ok single line: '135'

Test #125:

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

input:

249 47
2636226 789911178 1
523913341 999886182 1
132226333 999886182 1
70634129 999886182 1
2636226 184354887 1
490701347 999886182 1
778538789 999886182 1
2636226 825112142 1
521517365 999886182 1
523836136 999886182 1
2636226 617493451 1
2636226 589838542 1
594227435 999886182 1
2636226 649620090 ...

output:

155

result:

ok single line: '155'

Test #126:

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

input:

249 240
6078164 421691212 1
6078164 10322263 1
6078164 265917186 1
6078164 512001064 1
6078164 248102113 1
416709451 999683862 1
6078164 919257627 1
279020241 999683862 1
158272189 999683862 1
6078164 89552089 1
606303245 999683862 1
6078164 606846228 1
6078164 811982572 1
329587265 999683862 1
7453...

output:

9

result:

ok single line: '9'

Test #127:

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

input:

249 16
175553 164358081 1
175553 301066978 1
175553 397025066 1
175553 731740872 1
269003388 998425024 1
175553 199443511 1
175553 353383138 1
175553 841028898 1
175553 169423872 1
175553 392806144 1
175553 397025066 1
175553 556822745 1
175553 386450343 1
175553 789295221 1
175553 600425822 1
17555...

output:

225

result:

ok single line: '225'

Test #128:

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

input:

250 248
396899459 995225956 1
840666947 995225956 1
14785648 995225956 1
915851877 995225956 1
777964926 995225956 1
696118859 995225956 1
43725469 995225956 1
855075703 995225956 1
294982879 995225956 1
376418280 995225956 1
898706711 995225956 1
770310374 995225956 1
898706711 995225956 1
91362748...

output:

2

result:

ok single line: '2'

Test #129:

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

input:

250 10
8951199 724662022 1
970936713 997979281 1
84656474 997979281 1
562441981 997979281 1
8951199 646845743 1
903277432 997979281 1
570775376 997979281 1
196114910 997979281 1
903277432 997979281 1
522824410 997979281 1
143902311 997979281 1
8951199 310666790 1
758761506 997979281 1
929443224 9979...

output:

230

result:

ok single line: '230'

Test #130:

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

input:

250 137
261875864 999189129 1
3234969 641489553 1
695897696 999189129 1
3234969 460130679 1
3234969 807890353 1
800841635 999189129 1
3234969 862680077 1
3234969 635706775 1
3234969 868275339 1
3234969 675524239 1
3234969 786919073 1
3234969 699970291 1
455420636 999189129 1
519560541 999189129 1
63...

output:

96

result:

ok single line: '96'

Test #131:

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

input:

250 83
265287 464286507 1
265287 985530655 1
927209875 995305832 1
265287 724796515 1
265287 106054924 1
265287 125849666 1
265287 850804228 1
265287 169780874 1
265287 638955464 1
265287 33786816 1
265287 440074503 1
265287 441711331 1
265287 24092472 1
265287 502416992 1
265287 335096948 1
265287 ...

output:

161

result:

ok single line: '161'

Test #132:

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

input:

2496 1505
368754955 368754955 524869228
368754955 368754955 238333666
368754955 368754955 515930437
368754955 368754955 273493419
368754955 368754955 15993029
368754955 368754955 654956425
368754955 368754955 160517905
368754955 368754955 16095426
368754955 368754955 494023857
368754955 368754955 71...

output:

202673160139

result:

ok single line: '202673160139'

Test #133:

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

input:

2496 1127
913233732 913233732 192422462
431108858 913233732 472094457
913233732 913233732 876221398
431108858 913233732 680644288
431108858 913233732 305535346
431108858 913233732 15306574
913233732 913233732 792602734
431108858 431108858 383492601
913233732 913233732 709509047
431108858 431108858 2...

output:

375875988367

result:

ok single line: '375875988367'

Test #134:

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

input:

2496 1967
307921843 464788731 815390158
112057147 216875602 298415416
411333107 665382757 344924326
517279500 574250584 134643770
330199231 756843833 722876428
194895613 538848285 530369871
211454655 451515081 428332465
259541693 400382105 146496776
538848285 838476760 230967594
314772298 891955959 ...

output:

55571436850

result:

ok single line: '55571436850'

Test #135:

score: 0
Accepted
time: 120ms
memory: 3700kb

input:

2496 671
124145347 409061083 677371396
337839584 369250865 631323336
369250865 446462280 223897500
183081551 618209016 621416102
223776789 565979032 84556599
548587656 827218708 824198152
49182346 217951453 845507526
146367255 746170518 98362833
614390843 696249674 890457919
11412402 663380400 44781...

output:

613215016245

result:

ok single line: '613215016245'

Test #136:

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

input:

2496 574
9512927 491997238 186066776
394402758 463333914 209083234
616484941 975448841 703580959
449968526 688742130 805126725
679648600 920871417 245677970
371788047 878312319 562942500
529163419 618496803 556069895
120520155 475468511 652913167
507877293 559929123 962320616
180791306 187672428 278...

output:

637998460818

result:

ok single line: '637998460818'

Test #137:

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

input:

2497 1017
711938943 711938943 807173411
711938943 711938943 999893409
711938943 711938943 835724166
711938943 711938943 350941336
711938943 711938943 170240588
711938943 711938943 948996474
711938943 711938943 340474195
711938943 711938943 237969810
711938943 711938943 364334065
711938943 711938943 ...

output:

446882030835

result:

ok single line: '446882030835'

Test #138:

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

input:

2497 1612
211851525 696609208 866682902
211851525 696609208 409894547
211851525 696609208 393159017
211851525 696609208 963892010
211851525 696609208 178966068
211851525 211851525 867403027
211851525 696609208 307710243
696609208 696609208 405806458
211851525 696609208 717570564
211851525 696609208 ...

output:

151607019271

result:

ok single line: '151607019271'

Test #139:

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

input:

2497 1125
144574933 657883805 734392129
319483359 558193537 75927180
395617620 891519211 611550580
65076404 935784838 725926831
87640464 386921274 250012185
144574933 223069731 840326122
223069731 264909298 261339947
57709746 919836413 580834405
57709746 558193537 779216284
258664880 376020405 62701...

output:

386456544026

result:

ok single line: '386456544026'

Test #140:

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

input:

2497 569
605570378 676979927 616236863
155155308 252272303 53741418
59208466 549529090 196582163
402132938 567518154 857784850
99753605 752082542 806326752
236964426 675202746 961674858
20048136 671801843 265880615
32296232 645913946 982365548
504972275 505034038 677633790
210966804 285982721 950260...

output:

652421379857

result:

ok single line: '652421379857'

Test #141:

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

input:

2497 480
84918424 746358341 365439998
230020542 496284525 609937610
48737527 674133563 930469294
59870779 719323777 368706898
592667746 651785181 790630401
83911886 393415804 271008651
13275442 489772511 464621932
656845615 789486087 968298797
349242504 740963206 538157834
47939646 251194984 2746482...

output:

677643147680

result:

ok single line: '677643147680'

Test #142:

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

input:

2498 2420
350090227 350090227 89477593
350090227 350090227 56420449
350090227 350090227 715326408
350090227 350090227 428389253
350090227 350090227 469712338
350090227 350090227 388260715
350090227 350090227 960621973
350090227 350090227 900035681
350090227 350090227 89420081
350090227 350090227 725...

output:

1216886254

result:

ok single line: '1216886254'

Test #143:

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

input:

2498 1126
432785681 744825900 540943342
432785681 744825900 52727341
432785681 744825900 465386236
432785681 432785681 392363925
432785681 744825900 52396791
432785681 432785681 159690968
432785681 744825900 527850457
432785681 744825900 428120315
432785681 744825900 430664785
744825900 744825900 11...

output:

377031336671

result:

ok single line: '377031336671'

Test #144:

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

input:

2498 2115
370133479 822598353 358426805
87227423 619808800 148406241
100471718 859693627 27919939
864410830 940859455 22242596
335756469 959251268 221858341
281520829 619808800 710090886
334935178 887488703 799380132
812726480 931649159 720204739
368623908 965547233 32497678
124235938 908093346 4847...

output:

29128365784

result:

ok single line: '29128365784'

Test #145:

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

input:

2498 1286
598333796 811890031 700326522
134637844 968709187 886224908
383762403 663250314 169266826
552325485 589593532 948929406
581838296 971241860 378353801
892776261 929319508 804184267
189439375 297302361 686253704
153342242 315958434 866368264
315958434 770957572 610033853
115297774 190817754 ...

output:

292042751290

result:

ok single line: '292042751290'

Test #146:

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

input:

2498 493
741934953 812666054 972659835
99953106 252478895 887509817
329051343 353453973 837036346
139039301 194770282 389533989
397150782 812312558 584605882
165783541 454622945 633161510
289666508 377488219 518951064
716965775 839870723 763426579
26975234 723571103 421700229
519650189 733682044 951...

output:

621723403526

result:

ok single line: '621723403526'

Test #147:

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

input:

2499 1973
398306919 398306919 371781775
398306919 398306919 112947489
398306919 398306919 35120137
398306919 398306919 505837170
398306919 398306919 328992600
398306919 398306919 532557659
398306919 398306919 580769750
398306919 398306919 121910064
398306919 398306919 664762993
398306919 398306919 1...

output:

52632338673

result:

ok single line: '52632338673'

Test #148:

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

input:

2499 114
653719836 653719836 69979589
88009888 653719836 990527431
88009888 88009888 982323855
88009888 88009888 380644351
88009888 653719836 925827513
88009888 653719836 306754716
88009888 653719836 897733774
88009888 653719836 300691068
88009888 653719836 143759006
88009888 88009888 994340095
6537...

output:

1032428790181

result:

ok single line: '1032428790181'

Test #149:

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

input:

2499 2156
127879861 909802560 277428776
217393995 924321023 780693814
171239429 176689573 444289298
149847489 222229932 613525657
579380621 924321023 43961394
780586666 951433569 725079842
909802560 961433118 337420318
2312685 869206384 154542369
120993242 240087589 140554879
327217831 961433118 902...

output:

22914726822

result:

ok single line: '22914726822'

Test #150:

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

input:

2499 493
10217598 158516971 639191990
21668581 792676193 163418798
714987538 768327930 141951490
700934777 978794195 480265450
486292155 778041926 245348146
108028293 264088462 86885165
923712798 996162539 401594089
23011467 605329103 45338275
664410617 763801184 542433917
469587419 663851316 254637...

output:

648844071989

result:

ok single line: '648844071989'

Test #151:

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

input:

2499 1849
786290040 843879306 232136422
737758066 814274759 796250489
814822 499590500 47613871
219263147 236893895 373241414
44207353 781784274 963799992
575654817 876818481 206348152
413231293 820079335 736254332
283129588 562129465 682565115
139536532 895261180 647532407
136320171 267785628 48324...

output:

88273502710

result:

ok single line: '88273502710'

Test #152:

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

input:

2500 437
15537228 15537228 955712766
15537228 15537228 711361320
15537228 15537228 730577115
15537228 15537228 210968560
15537228 15537228 880918093
15537228 15537228 569245800
15537228 15537228 20656649
15537228 15537228 303001939
15537228 15537228 562477060
15537228 15537228 88692475
15537228 1553...

output:

847614815114

result:

ok single line: '847614815114'

Test #153:

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

input:

2500 703
132260823 132260823 506220285
132260823 132260823 90350025
854983301 854983301 949047594
132260823 854983301 871947657
854983301 854983301 81039168
132260823 132260823 255822413
132260823 854983301 189858626
132260823 854983301 34476928
132260823 132260823 884375716
132260823 132260823 7896...

output:

614112090072

result:

ok single line: '614112090072'

Test #154:

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

input:

2500 149
236825139 494301544 434788470
439070959 985160918 963905879
129449720 971468071 775194537
7870024 824707369 783174319
7870024 737408837 441685712
264729353 943681719 128043419
820344792 856194136 650322955
971468071 986567663 119656203
677595149 697892351 26645563
670104033 875371936 810701...

output:

925764231820

result:

ok single line: '925764231820'

Test #155:

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

input:

2500 2056
247394002 820977099 351877012
297986496 986973409 614957798
555637438 932024014 885198865
758440226 769300004 731663915
153380347 369284454 848378514
590844970 811981794 164823820
91321359 277379057 914613807
123290801 906842929 351003139
170075992 509941616 975334629
186366251 669282578 8...

output:

40437691115

result:

ok single line: '40437691115'

Test #156:

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

input:

2500 1400
496887954 948753913 66875485
341575396 788812378 31147262
529944880 584311643 910711250
782184411 934255794 742885369
382663467 680965337 561380414
746280584 921271137 861283428
497422803 672699582 743649734
602686678 638169203 535034654
704545959 886160681 857702820
595576721 907933543 66...

output:

240618381092

result:

ok single line: '240618381092'

Test #157:

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

input:

2498 601
814539793 999460826 80023164
327850753 999460826 440662041
991814880 999460826 744580473
694500628 999460826 404047651
790840958 999460826 430900705
257518642 999460826 697222103
533995211 999460826 403234519
681443360 999460826 192454131
315823539 999460826 778285651
160114356 999460826 95...

output:

731613555075

result:

ok single line: '731613555075'

Test #158:

score: 0
Accepted
time: 28ms
memory: 3688kb

input:

2498 1445
966364792 999994152 664022870
105146 873834362 893694399
645902986 999994152 267509472
64960045 999994152 530252059
105146 78433387 659305480
105146 173408884 784591457
961156609 999994152 413688129
328261599 999994152 302240397
477277773 999994152 515758770
828218677 999994152 589953936
3...

output:

226909667465

result:

ok single line: '226909667465'

Test #159:

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

input:

2498 1328
455315 950292507 935735378
495413860 999937347 406154059
641636863 999937347 404494492
728699786 999937347 928428342
553125450 999937347 370409700
404355838 999937347 72864651
980735330 999937347 638293171
455315 411162869 422311237
364533411 999937347 98790294
455315 808379465 943870371
4...

output:

265023053589

result:

ok single line: '265023053589'

Test #160:

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

input:

2498 2469
38157 60332319 48094573
38157 558630423 549906161
38157 300321045 249103608
38157 648056511 889010280
38157 822367948 553022065
38157 53970505 586123708
38157 75056766 352445156
38157 189371361 975380517
38157 795634103 678523474
38157 595440110 776806668
38157 152400949 849031216
38157 58...

output:

245721409

result:

ok single line: '245721409'

Test #161:

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

input:

2499 1972
407110074 999688339 344282405
328636635 999688339 937226788
905357797 999688339 844056949
617771197 999688339 879551342
887454334 999688339 814465916
579478789 999688339 437452138
824079908 999688339 15065827
97501801 999688339 925197109
96587747 999688339 528037207
351495215 999688339 390...

output:

56654510279

result:

ok single line: '56654510279'

Test #162:

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

input:

2499 1642
128783597 999910214 723372818
922240989 999910214 967795395
1191422 123700459 703580113
1191422 764431014 818541922
737586665 999910214 654475171
400229806 999910214 244373517
881698592 999910214 79778793
958903628 999910214 632263445
259328732 999910214 99334408
32741145 999910214 7958389...

output:

153378567868

result:

ok single line: '153378567868'

Test #163:

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

input:

2499 672
207523418 999733813 801821105
481799986 999733813 244116973
1387526 196369889 378576307
908094076 999733813 484017643
883653948 999733813 779656718
1387526 583781311 647116557
1387526 745755174 231010930
304511085 999733813 796719557
1387526 103905256 779928112
1387526 174230260 590141541
1...

output:

616649499413

result:

ok single line: '616649499413'

Test #164:

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

input:

2499 1005
591853931 999177534 519092054
1043558 745880846 247582572
1043558 736289292 763372915
1043558 41509411 156034804
1043558 293734733 102401927
1043558 586988690 885527652
1043558 54042245 581324090
1043558 956827286 936973375
1043558 539882667 560739720
1043558 802575194 169316762
1043558 66...

output:

447743512908

result:

ok single line: '447743512908'

Test #165:

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

input:

2500 1184
124051673 999105642 437039369
183810470 999105642 274616499
830606257 999105642 863813853
817122082 999105642 319348505
341720929 999105642 80373758
16098310 999105642 307485243
885327888 999105642 650934511
363176629 999105642 445322552
718938860 999105642 356129545
251337488 999105642 30...

output:

354123731918

result:

ok single line: '354123731918'

Test #166:

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

input:

2500 2062
246031766 999378235 439661879
210507 746754513 577368507
435889296 999378235 758767392
210507 328114245 973873540
210507 870817901 532781585
368421180 999378235 537977526
534588354 999378235 895097624
64413809 999378235 549569227
5419527 999378235 342966972
198995545 999378235 817984498
21...

output:

38747854980

result:

ok single line: '38747854980'

Test #167:

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

input:

2500 2245
303337384 999863699 91213154
510250135 999863699 71475800
320214870 999863699 965006822
575570 902877372 170266590
302817277 999863699 993155191
575570 85161559 569658927
203453193 999863699 321566701
575570 505330557 917438821
575570 526536165 852272576
575570 259579036 215698043
20390881...

output:

14666076218

result:

ok single line: '14666076218'

Test #168:

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

input:

2500 1992
954843 149299245 921484977
954843 562740622 869489119
954843 101387366 452351826
954843 943200914 872588967
954843 610407118 881587665
954843 881403891 3928946
954843 922181808 856496235
954843 859856368 334884022
954843 208610028 166613874
954843 37989599 143183935
954843 648310363 827315...

output:

52606888335

result:

ok single line: '52606888335'

Test #169:

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

input:

2498 1
740414026 740414026 682362951
740414026 740414026 49781169
740414026 740414026 894368353
740414026 740414026 201846585
740414026 740414026 668002204
740414026 740414026 286086687
740414026 740414026 274540672
740414026 740414026 403960534
740414026 740414026 910333450
740414026 740414026 7782...

output:

1243815989704

result:

ok single line: '1243815989704'

Test #170:

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

input:

2498 1
376815978 784154428 799475096
146846757 785999437 837169657
352897418 447518164 260111342
76210743 403812323 918289074
181528752 403812323 501057170
547559559 708821240 710699164
366655650 910113091 912200598
145605162 759720168 836619825
105846076 757272250 993492094
159308475 243618997 8044...

output:

1221239123188

result:

ok single line: '1221239123188'

Test #171:

score: 0
Accepted
time: 36ms
memory: 3700kb

input:

2498 1
481531493 575959962 846989814
292115184 845546193 357012603
193948012 556114064 862201258
176895958 825932485 765183181
71685264 321625312 726377491
589856171 872807561 27916123
169518375 333900883 702089299
980334902 990336734 106813377
415899886 449406486 294544928
8106270 179715350 6385416...

output:

1197466006246

result:

ok single line: '1197466006246'

Test #172:

score: 0
Accepted
time: 52ms
memory: 3772kb

input:

2498 1
473284820 616994625 218259130
439882485 657362310 103879944
304692620 321068623 467502082
229286624 410590306 190972126
208887976 786996328 926435246
466629937 738697087 930697958
345537760 389109539 142233883
669293423 892187202 672351501
843370796 995065998 395613671
71926871 955815223 4666...

output:

1224278752800

result:

ok single line: '1224278752800'

Test #173:

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

input:

2499 1
175218713 175218713 608329810
175218713 175218713 724041609
175218713 175218713 537201147
175218713 175218713 718784204
175218713 175218713 96474118
175218713 175218713 159517409
175218713 175218713 421604420
175218713 175218713 919068044
175218713 175218713 637680011
175218713 175218713 7862...

output:

1260612494575

result:

ok single line: '1260612494575'

Test #174:

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

input:

2499 1
27143533 180138892 729402421
72618608 823840951 500815745
249293350 866395015 748913714
608555748 769607159 12822102
765175253 779024558 856305812
205174259 720469320 577662829
429220889 762936977 914790596
267423944 349290391 659832223
208123652 276280851 668980271
762936977 866395015 610930...

output:

1209098878876

result:

ok single line: '1209098878876'

Test #175:

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

input:

2499 1
223389269 354869729 672278844
37086638 833270463 114294013
22484842 433429998 143114308
312262166 434331330 699207640
127815258 628472068 484054766
298759408 907627960 754103831
216687412 578002786 945078360
243021621 959233524 920110746
84453850 669371859 93769540
432432324 772394178 9462369...

output:

1208076073784

result:

ok single line: '1208076073784'

Test #176:

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

input:

2499 1
688299105 833927125 371190405
394552744 813731277 768333356
510351989 919730928 645745304
595297617 936184837 686545831
97329022 519292591 896953781
86281274 518822462 799269897
101383348 661811365 693584529
535329794 946013786 637767378
91671640 742416150 8944153
86424174 915529194 635599094...

output:

1221733062124

result:

ok single line: '1221733062124'

Test #177:

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

input:

2500 1
861406195 861406195 941646605
861406195 861406195 15058113
861406195 861406195 637023741
861406195 861406195 685507943
861406195 861406195 442553232
861406195 861406195 19761769
861406195 861406195 665639413
861406195 861406195 65968704
861406195 861406195 666433167
861406195 861406195 377169...

output:

1254903429773

result:

ok single line: '1254903429773'

Test #178:

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

input:

2500 1
294946196 395007211 133300553
590619890 655422496 263263663
754160892 990798090 920118720
307247218 474792879 648992340
175416154 867916821 576013886
354033474 600930103 35197630
248745546 778798217 164316986
581833003 754160892 963755053
431076992 778798217 708232031
165880752 672987607 5368...

output:

1228524080617

result:

ok single line: '1228524080617'

Test #179:

score: 0
Accepted
time: 35ms
memory: 3864kb

input:

2500 1
77553246 649972787 639869511
236600589 799335427 386150323
134619917 623518654 356370793
383853788 674311846 297132662
163285474 484965589 69926419
382282851 582084327 626583867
463398146 897589995 139586429
767652028 920154567 915468051
581362908 605223890 371013170
186533049 309285431 45243...

output:

1227763857099

result:

ok single line: '1227763857099'

Test #180:

score: 0
Accepted
time: 53ms
memory: 3776kb

input:

2500 1
107607642 293083323 617230901
157878171 906382175 175390866
188903213 965267179 696293479
617468779 832369623 350467980
578082318 581555780 437158102
357567905 921969936 832941465
69586653 199375548 600306029
141563331 155812468 898502197
83935326 512041182 771898461
485046112 717551275 52873...

output:

1221451949791

result:

ok single line: '1221451949791'

Test #181:

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

input:

2498 1300
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
628671776 628671776 1
6286...

output:

1198

result:

ok single line: '1198'

Test #182:

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

input:

2498 995
754633347 902102376 1
40472404 348813215 1
128597856 459968968 1
138289730 594983502 1
287765656 932117431 1
249002901 820386216 1
553788039 978511101 1
454548901 648619404 1
864610200 955223493 1
241423507 670145384 1
98149580 138289730 1
418358276 848590731 1
677349450 848590731 1
5447030...

output:

1160

result:

ok single line: '1160'

Test #183:

score: 0
Accepted
time: 37ms
memory: 3784kb

input:

2498 1186
85759477 802811012 1
253536253 904616023 1
290017214 924600220 1
180572485 975584157 1
507508428 812623250 1
388390597 780144133 1
412314255 522272833 1
308347485 707746684 1
153181548 645781667 1
412314255 813591731 1
546680353 560999458 1
561182752 703365247 1
19306780 932259911 1
798773...

output:

1039

result:

ok single line: '1039'

Test #184:

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

input:

2498 1413
779078411 955906016 1
788103509 817088050 1
341020398 601263672 1
98146298 919778781 1
181960753 360284444 1
105182721 111309520 1
432946163 705089100 1
81777639 627858974 1
142712553 706056806 1
325777435 488226195 1
143564529 417276107 1
447829549 599160961 1
312132896 976307392 1
730258...

output:

920

result:

ok single line: '920'

Test #185:

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

input:

2499 940
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
971855764 971855764 1
97185...

output:

1559

result:

ok single line: '1559'

Test #186:

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

input:

2499 153
38966713 996032267 1
285843782 290533191 1
290533191 810133103 1
423027614 510729594 1
510729594 951201993 1
306584969 769082822 1
620973954 659918379 1
378455014 383706887 1
286842531 756912254 1
756912254 959683750 1
348608150 423027614 1
304327025 688787338 1
61959666 778347659 1
5828642...

output:

1902

result:

ok single line: '1902'

Test #187:

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

input:

2499 1959
639591851 999973523 1
137475031 721218430 1
30389310 618370697 1
329617273 368658145 1
683939334 698228680 1
78968657 992157231 1
31545273 687974122 1
813588606 989906561 1
539841664 962904888 1
360944766 679035723 1
47814718 658224750 1
28069097 580440545 1
187858500 230282603 1
352504715...

output:

503

result:

ok single line: '503'

Test #188:

score: 0
Accepted
time: 35ms
memory: 3872kb

input:

2499 1786
35648381 51714008 1
541291938 864149057 1
447789476 993578102 1
310685898 735108785 1
492878107 764453874 1
632176825 748786748 1
213275513 901865832 1
548857976 678616475 1
396245984 680164035 1
516882158 708336976 1
29341243 371750603 1
190133567 974390704 1
282108802 388416167 1
4801465...

output:

637

result:

ok single line: '637'

Test #189:

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

input:

2500 1565
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
884053369 884053369 1
8840...

output:

935

result:

ok single line: '935'

Test #190:

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

input:

2500 1073
360234947 388045691 1
425329688 672629559 1
493479271 656761203 1
493773797 656761203 1
399351311 656761203 1
672629559 727033672 1
514059227 941991085 1
360234947 462566831 1
144775095 265855354 1
169962237 237203765 1
292551579 870781116 1
574863048 671629826 1
654079760 894462226 1
6463...

output:

1137

result:

ok single line: '1137'

Test #191:

score: 0
Accepted
time: 45ms
memory: 3780kb

input:

2500 684
441628580 731786065 1
102074277 222254363 1
448207435 550081703 1
146988348 379413936 1
66321068 561701496 1
60122624 404702220 1
597486121 826361229 1
266543900 291205244 1
41576597 331896819 1
504863054 878823678 1
761937902 924760237 1
232446272 583889856 1
429629083 691889324 1
15002591...

output:

1229

result:

ok single line: '1229'

Test #192:

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

input:

2500 28
24263988 307490432 1
488010054 632916159 1
207409522 662958505 1
289683095 744967097 1
417129330 419405761 1
59625111 345181330 1
97960187 190506389 1
331658013 562339844 1
354054316 889505654 1
571236432 991477112 1
611693179 957280268 1
421706764 735244299 1
204972120 545976627 1
33381721 ...

output:

2228

result:

ok single line: '2228'

Test #193:

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

input:

2498 1979
897581010 999791360 1
556274937 999791360 1
830780312 999791360 1
465026331 999791360 1
544463473 999791360 1
799494447 999791360 1
7357918 999791360 1
534827000 999791360 1
550177507 999791360 1
775475903 999791360 1
863566096 999791360 1
445110892 999791360 1
213938324 999791360 1
398059...

output:

519

result:

ok single line: '519'

Test #194:

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

input:

2498 2365
850302715 999937197 1
256117 244039121 1
256117 391575607 1
731967018 999937197 1
746462607 999937197 1
24457068 999937197 1
256117 612958873 1
539605794 999937197 1
292801749 999937197 1
100904448 999937197 1
301138675 999937197 1
144063600 999937197 1
222967343 999937197 1
218801470 9999...

output:

133

result:

ok single line: '133'

Test #195:

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

input:

2498 208
650737 391198528 1
250606459 999638464 1
650737 33471175 1
650737 448293496 1
609183295 999638464 1
650737 897717079 1
650737 136438532 1
650737 512811461 1
480826708 999638464 1
386082134 999638464 1
109655632 999638464 1
382503286 999638464 1
475940863 999638464 1
916994458 999638464 1
45...

output:

2082

result:

ok single line: '2082'

Test #196:

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

input:

2498 891
375261 775547172 1
375261 936924860 1
375261 727569033 1
375261 392681481 1
375261 900471436 1
375261 320454479 1
375261 244648502 1
375261 737316544 1
375261 941485637 1
375261 794924448 1
375261 52508983 1
375261 268535176 1
375261 230145302 1
375261 507136090 1
30105852 999957482 1
37526...

output:

1548

result:

ok single line: '1548'

Test #197:

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

input:

2499 939
908118907 999865529 1
453241439 999865529 1
321079015 999865529 1
253665471 999865529 1
795636068 999865529 1
80948903 999865529 1
118383386 999865529 1
205279881 999865529 1
3416896 999865529 1
837111067 999865529 1
73718346 999865529 1
297910872 999865529 1
532362200 999865529 1
383677926...

output:

1560

result:

ok single line: '1560'

Test #198:

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

input:

2499 2138
18617 265606214 1
873888844 999537487 1
984330859 999537487 1
761807215 999537487 1
256267455 999537487 1
478423004 999537487 1
914061518 999537487 1
18617 622924998 1
661936528 999537487 1
18617 183686419 1
303795284 999537487 1
883462332 999537487 1
406630661 999537487 1
604798954 999537...

output:

361

result:

ok single line: '361'

Test #199:

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

input:

2499 1168
709671566 999925576 1
521525900 999925576 1
220689 494677272 1
201919509 999925576 1
220689 224368277 1
279459879 999925576 1
827728580 999925576 1
220689 27127875 1
973401197 999925576 1
797119492 999925576 1
220689 161360550 1
220689 545451803 1
220689 774251626 1
220689 479103982 1
5356...

output:

1103

result:

ok single line: '1103'

Test #200:

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

input:

2499 942
1133137 831643438 1
1133137 558842277 1
1133137 30500301 1
1133137 610102742 1
1133137 644828473 1
1133137 292063448 1
1133137 147738122 1
1133137 291509484 1
1133137 519427272 1
1133137 35172673 1
1133137 912450597 1
1133137 855674976 1
1133137 597536597 1
1133137 594834473 1
1133137 67140...

output:

1495

result:

ok single line: '1495'

Test #201:

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

input:

2500 2312
712289460 999448789 1
950871095 999448789 1
150116493 999448789 1
290245171 999448789 1
75832754 999448789 1
749629449 999448789 1
977666999 999448789 1
308828292 999448789 1
164199351 999448789 1
128790989 999448789 1
526060283 999448789 1
772437498 999448789 1
463663722 999448789 1
66057...

output:

188

result:

ok single line: '188'

Test #202:

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

input:

2500 486
928561 161819949 1
811727533 999999068 1
115054985 999999068 1
480800445 999999068 1
493756038 999999068 1
109074171 999999068 1
582071321 999999068 1
202559379 999999068 1
905577724 999999068 1
205895260 999999068 1
337362486 999999068 1
108661867 999999068 1
928561 250835310 1
928561 8395...

output:

1528

result:

ok single line: '1528'

Test #203:

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

input:

2500 669
747203 387104102 1
191386529 999310642 1
747203 939747338 1
388628725 999310642 1
173394237 999310642 1
478017519 999310642 1
747203 591459592 1
747203 248452797 1
747203 837831050 1
747203 165484044 1
913631862 999310642 1
747203 765487112 1
747203 744874113 1
156212224 999310642 1
747203 ...

output:

1310

result:

ok single line: '1310'

Test #204:

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

input:

2500 620
207686 145261376 1
207686 241532609 1
207686 720795258 1
207686 407578339 1
207686 714453748 1
207686 30830713 1
207686 383620569 1
207686 602509961 1
207686 517207576 1
207686 27729865 1
207686 345933739 1
207686 239262374 1
207686 185328490 1
207686 169850664 1
207686 932286157 1
207686 1...

output:

1806

result:

ok single line: '1806'