QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#608941#2556. Yet Another Interval Graph Problemydzr00000RE 4ms18740kbC++171.2kb2024-10-04 09:29:462024-10-04 09:29:48

Judging History

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

  • [2024-10-04 09:29:48]
  • 评测
  • 测评结果:RE
  • 用时:4ms
  • 内存:18740kb
  • [2024-10-04 09:29:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct Segment{
	int l,r,w;
}a[2001];
using ll=long long;
priority_queue<ll,vector<ll>,greater<ll>>q;
ll g[4001][4001];
ll dp[4001];
vector<int>dat;
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	long long all=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d %d",&a[i].l,&a[i].r,&a[i].w);
		dat.push_back(a[i].l);
		dat.push_back(a[i].r);
		all+=a[i].w;
	}
	sort(dat.begin(),dat.end());
	dat.erase(unique(dat.begin(),dat.end()),dat.end());
	for(int i=1;i<=n;i++)
	{
		a[i].l=lower_bound(dat.begin(),dat.end(),a[i].l)-dat.begin()+1;
		a[i].r=lower_bound(dat.begin(),dat.end(),a[i].r)-dat.begin()+1;
	}
	sort(a+1,a+n+1,[&](Segment S,Segment T){
		return S.r<T.r;
	});
	int k=dat.size();
	for(int i=1;i<=k;i++)
	{
		while(!q.empty())
			q.pop();
		long long sum=0;
		int r=0;
		for(int j=1;j<=n;j++)
			if(a[j].l>=i)
			{
				r=max(r,a[j].r);
				q.push(a[j].w);
				sum+=a[j].w;
				if(q.size()>m)
				{
					sum-=q.top();
					q.pop();
				}
				g[i][r]=sum;
			}
	}
	dp[0]=0;
	for(int i=1;i<=k;i++)
		for(int j=0;j<i;j++)
			dp[i]=max(dp[i],dp[j]+g[j+1][i]);
	printf("%lld\n",all-dp[k]);

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0ms
memory: 3864kb

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: 0ms
memory: 3940kb

input:

1 1
260947663 693934985 986106006

output:

0

result:

ok single line: '0'

Test #4:

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

input:

2 2
148610427 148610427 611594176
148610427 148610427 241979785

output:

0

result:

ok single line: '0'

Test #5:

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

input:

2 2
189944467 208945642 113891402
208945642 235053342 250664551

output:

0

result:

ok single line: '0'

Test #6:

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

input:

2 2
259102823 862504466 73871288
91533165 259102823 447104717

output:

0

result:

ok single line: '0'

Test #7:

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

input:

2 2
634621570 811155007 87507743
299710238 563644023 98163867

output:

0

result:

ok single line: '0'

Test #8:

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

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: 0ms
memory: 3884kb

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: 0ms
memory: 4000kb

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: 0ms
memory: 3884kb

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: 0ms
memory: 3940kb

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: 0ms
memory: 3904kb

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: 0ms
memory: 4024kb

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: 0ms
memory: 3924kb

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: 0ms
memory: 3808kb

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: 3976kb

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: 0ms
memory: 4004kb

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: 0ms
memory: 3980kb

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: 0ms
memory: 3928kb

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: 3960kb

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: 0ms
memory: 3928kb

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: 0ms
memory: 3904kb

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: 4016kb

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: 0ms
memory: 3980kb

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: 1ms
memory: 5916kb

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: 0ms
memory: 3944kb

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: 4012kb

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: 0ms
memory: 3888kb

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: 0ms
memory: 3972kb

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: 3832kb

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: 0ms
memory: 3924kb

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: 0ms
memory: 3828kb

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: 0ms
memory: 4004kb

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: 0ms
memory: 4064kb

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: 3860kb

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: 0ms
memory: 3876kb

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: 0ms
memory: 3972kb

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: 0ms
memory: 3936kb

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: 0ms
memory: 3880kb

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: 0ms
memory: 6056kb

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: 0ms
memory: 6072kb

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: 0ms
memory: 4092kb

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: 3980kb

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: 0ms
memory: 3876kb

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: 1ms
memory: 6016kb

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: 0ms
memory: 3932kb

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: 0ms
memory: 3936kb

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: 0ms
memory: 3948kb

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: 4008kb

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: 0ms
memory: 4096kb

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: 0ms
memory: 3948kb

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: 0ms
memory: 3880kb

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: 0ms
memory: 3844kb

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: 0ms
memory: 3944kb

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: 0ms
memory: 3904kb

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: 0ms
memory: 3972kb

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: 0ms
memory: 3908kb

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: 3984kb

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: 3984kb

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: 0ms
memory: 3984kb

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: 0ms
memory: 3984kb

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: 0ms
memory: 3864kb

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: 0ms
memory: 3856kb

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: 0ms
memory: 4032kb

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: 0ms
memory: 16484kb

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: 0ms
memory: 18740kb

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: 0ms
memory: 4000kb

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: 0ms
memory: 3844kb

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: 0ms
memory: 14492kb

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: 4ms
memory: 18704kb

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: 0ms
memory: 3856kb

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: 4024kb

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: 14400kb

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: 4ms
memory: 16484kb

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: 0ms
memory: 3892kb

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: 1ms
memory: 8032kb

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: 14556kb

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: 4ms
memory: 18536kb

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: 0ms
memory: 3996kb

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: 0ms
memory: 3924kb

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: 16332kb

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: 0ms
memory: 18380kb

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: 0ms
memory: 8092kb

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: 1ms
memory: 10080kb

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: 0ms
memory: 10032kb

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: 1ms
memory: 10088kb

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: 2ms
memory: 8148kb

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: 8184kb

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: 1ms
memory: 10140kb

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: 1ms
memory: 8000kb

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: 2ms
memory: 8332kb

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: 1ms
memory: 8240kb

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: 1ms
memory: 10096kb

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: 1ms
memory: 8052kb

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: 3864kb

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: 0ms
memory: 4000kb

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: 2ms
memory: 14400kb

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: 0ms
memory: 16532kb

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: 0ms
memory: 3952kb

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: 0ms
memory: 4032kb

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: 0ms
memory: 16316kb

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: 2ms
memory: 16612kb

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: 0ms
memory: 3936kb

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: 0ms
memory: 3980kb

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: 16244kb

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: 18636kb

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: 0ms
memory: 3856kb

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: 3968kb

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: 0ms
memory: 16420kb

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: 2ms
memory: 18224kb

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: 0ms
memory: 3936kb

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: 0ms
memory: 4032kb

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: 0ms
memory: 14384kb

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: 0ms
memory: 18564kb

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: 0ms
memory: 3948kb

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: 0ms
memory: 4036kb

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: 0ms
memory: 16148kb

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: 0ms
memory: 18440kb

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: 0ms
memory: 10084kb

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: 1ms
memory: 8288kb

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: 1ms
memory: 8128kb

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: 1ms
memory: 10152kb

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: 1ms
memory: 10084kb

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: 1ms
memory: 10224kb

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: 1ms
memory: 10144kb

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: 1ms
memory: 8264kb

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: 0ms
memory: 10088kb

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: 1ms
memory: 9964kb

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: 0ms
memory: 10040kb

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: 1ms
memory: 8172kb

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: -100
Runtime Error

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:


result: