QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#112466#3045. Minimum Diameter Spanning TreeDitaMirikaAC ✓384ms15288kbC++142.6kb2023-06-11 21:12:002023-06-11 21:12:04

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
1 2 1
2 3 1
3 1 1

output:

2
2 1
3 1

result:

ok 

Test #2:

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

input:

6 7
1 2 10
2 3 20
1 3 30
3 4 1000
4 5 30
5 6 20
4 6 10

output:

1060
3 4
1 3
5 4
2 3
6 4

result:

ok 

Test #3:

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

input:

16 120
11 4 2
3 10 2
12 4 1
16 9 3
2 7 4
16 3 1
3 2 2
13 15 2
9 1 1
13 1 2
14 15 2
16 8 1
1 15 2
5 1 3
7 4 3
8 13 1
4 13 2
9 4 1
1 3 3
13 6 2
13 2 1
3 9 4
7 6 1
10 14 1
3 14 3
12 5 2
15 16 2
2 5 2
15 11 4
10 8 2
2 14 3
10 16 1
11 1 2
5 10 4
14 11 2
6 4 2
13 10 3
14 1 2
1 4 2
5 7 2
12 6 1
13 11 2
6 5...

output:

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

result:

ok 

Test #4:

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

input:

256 32640
142 82 7
78 125 3
66 149 6
31 236 2
226 136 3
167 225 3
120 135 5
124 79 3
138 17 5
1 90 1
128 38 4
44 190 3
38 43 6
46 12 6
32 232 4
137 7 2
58 139 3
40 13 5
29 181 5
184 205 1
171 186 4
135 237 5
173 163 3
98 4 2
248 97 5
99 93 4
139 247 5
205 144 5
38 194 5
108 144 4
222 67 5
104 77 5
2...

output:

15
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
60 1
61 1
62 1
...

result:

ok 

Test #5:

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

input:

125 7750
17 50 7
72 112 7
92 14 4
18 99 5
115 55 9
96 10 5
98 16 4
116 76 9
58 28 8
37 80 4
10 102 3
20 92 7
12 104 5
92 106 7
109 48 6
125 56 6
20 47 3
40 80 6
67 32 2
37 21 7
48 117 6
33 41 7
93 10 3
13 114 6
68 25 1
109 94 2
36 118 6
58 3 7
40 104 6
40 76 1
118 91 7
55 93 2
44 48 2
27 99 8
79 10 ...

output:

12
1 125
2 125
3 125
4 125
5 125
6 125
7 125
8 125
9 125
10 125
11 125
12 125
13 125
14 125
15 125
16 125
17 125
18 125
19 125
20 125
21 125
22 125
23 125
24 125
25 125
26 125
27 125
28 125
29 125
30 125
31 125
32 125
33 125
34 125
35 125
36 125
37 125
38 125
39 125
40 125
41 125
42 125
43 125
44 12...

result:

ok 

Test #6:

score: 0
Accepted
time: 102ms
memory: 10732kb

input:

343 58653
54 265 9
188 61 10
120 35 7
35 12 9
315 68 3
188 334 7
22 2 7
138 28 9
194 314 9
39 87 8
162 291 2
224 79 7
271 331 6
271 38 2
260 343 14
41 204 1
48 295 2
53 195 9
322 332 10
53 38 4
9 257 9
293 119 7
281 149 10
209 177 10
290 57 6
127 124 6
317 201 3
215 109 6
182 195 3
75 276 8
168 92 7...

output:

18
1 145
2 145
3 145
4 145
5 145
6 145
7 145
8 145
9 145
10 145
11 145
12 145
13 145
14 145
15 145
16 145
17 145
18 145
19 145
20 145
21 145
22 145
23 145
24 145
25 145
26 145
27 145
28 145
29 145
30 145
31 145
32 145
33 145
34 145
35 145
36 145
37 145
38 145
39 145
40 145
41 145
42 145
43 145
44 14...

result:

ok 

Test #7:

score: 0
Accepted
time: 354ms
memory: 15096kb

input:

500 124750
443 468 569963
305 222 835365
55 98 5648875
17 483 6871804
249 387 957143
262 188 5962213
276 44 1213886
113 429 5230975
25 336 3434848
489 27 8708218
446 126 6079086
430 164 4406225
12 85 4614009
153 346 633874
316 368 5101625
236 369 2292881
387 66 5274904
220 278 3980069
146 303 544564...

output:

9960452
1 485
2 485
3 485
4 485
5 485
6 485
7 485
8 485
9 485
10 485
11 485
12 485
13 485
14 485
15 485
16 485
17 485
18 485
19 485
20 485
21 485
22 485
23 485
24 485
25 485
26 485
27 485
28 485
29 485
30 485
31 485
32 485
33 485
34 485
35 485
36 485
37 485
38 485
39 485
40 485
41 485
42 485
43 485
...

result:

ok 

Test #8:

score: 0
Accepted
time: 54ms
memory: 8480kb

input:

256 32640
67 46 8826982
212 207 5853106
75 245 11953237
34 125 17259394
17 120 10969533
155 3 6675664
141 92 13332413
244 88 7639683
137 79 3970040
73 176 19125293
169 201 4299143
73 163 12142015
14 6 12113321
75 256 9291130
63 157 12832584
228 29 6772645
68 175 13691783
5 89 4302943
16 103 6727852
...

output:

26131854
138 155
64 138
23 155
1 138
2 155
3 155
4 155
5 155
6 138
7 138
8 155
9 155
10 155
11 138
12 155
13 155
14 155
15 155
16 155
17 155
18 155
19 155
20 155
21 155
22 138
24 155
25 155
26 155
27 155
28 138
29 155
30 155
31 155
32 155
33 138
34 155
35 138
36 138
37 155
38 155
39 155
40 155
41 13...

result:

ok 

Test #9:

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

input:

243 29403
29 23 3131302
11 3 4511503
12 185 16507040
115 35 13690920
31 170 6850162
116 51 4745664
144 112 14201854
39 63 10109135
120 78 11204668
183 78 7290363
40 107 16689635
67 136 93441
67 55 15947263
39 143 4693652
154 107 10604580
127 183 10496797
208 122 13041508
11 26 6647372
126 229 985041...

output:

21457553
120 148
180 120
134 148
1 120
2 148
3 120
4 120
5 120
6 120
7 120
8 120
9 148
10 120
11 120
12 148
13 120
14 120
15 148
16 120
17 120
18 120
19 120
20 148
21 120
22 148
23 148
24 120
25 120
26 148
27 148
28 148
29 148
30 120
31 120
32 120
33 120
34 148
35 120
36 148
37 120
38 120
39 120
40 ...

result:

ok 

Test #10:

score: 0
Accepted
time: 350ms
memory: 15260kb

input:

499 124251
461 265 336966683
376 414 284212683
366 413 337970820
9 149 355258271
325 156 315832696
113 375 354577875
32 433 345627841
376 161 335785529
366 42 319451479
385 172 321004557
98 236 360767420
444 326 313089369
36 115 337424941
392 238 340807288
85 347 336353275
116 372 371769911
391 13 3...

output:

733198522
1 406
2 406
3 406
4 406
5 406
6 406
7 406
8 406
9 406
10 406
11 406
12 406
13 406
14 406
15 406
16 406
17 406
18 406
19 406
20 406
21 406
22 406
23 406
24 406
25 406
26 406
27 406
28 406
29 406
30 406
31 406
32 406
33 406
34 406
35 406
36 406
37 406
38 406
39 406
40 406
41 406
42 406
43 40...

result:

ok 

Test #11:

score: 0
Accepted
time: 345ms
memory: 15224kb

input:

500 124750
493 130 351043307
208 348 326179963
83 94 342055956
163 348 373258823
197 409 325293509
261 88 324333155
23 100 321384496
344 479 358400743
260 100 342652394
448 3 317675245
283 349 361779182
414 197 327194724
37 459 389772936
401 126 344352426
60 46 312990080
313 242 318912361
198 98 325...

output:

738068891
1 266
2 266
3 266
4 266
5 266
6 266
7 266
8 266
9 266
10 266
11 266
12 266
13 266
14 266
15 266
16 266
17 266
18 266
19 266
20 266
21 266
22 266
23 266
24 266
25 266
26 266
27 266
28 266
29 266
30 266
31 266
32 266
33 266
34 266
35 266
36 266
37 266
38 266
39 266
40 266
41 266
42 266
43 26...

result:

ok 

Test #12:

score: 0
Accepted
time: 384ms
memory: 15120kb

input:

500 124750
263 149 823
1 65 751
53 409 870
292 352 762
379 122 767
484 74 812
115 497 832
297 334 823
210 41 809
420 268 807
95 216 752
186 423 791
427 358 776
118 223 775
459 211 808
162 343 751
210 119 809
439 195 844
154 221 822
363 390 822
339 270 807
153 15 837
426 330 773
354 315 762
317 303 7...

output:

1687
1 487
2 487
3 487
4 487
5 487
6 487
7 487
8 487
9 487
10 487
11 487
12 487
13 487
14 487
15 487
16 487
17 487
18 487
19 487
20 487
21 487
22 487
23 487
24 487
25 487
26 487
27 487
28 487
29 487
30 487
31 487
32 487
33 487
34 487
35 487
36 487
37 487
38 487
39 487
40 487
41 487
42 487
43 487
44 ...

result:

ok 

Test #13:

score: 0
Accepted
time: 339ms
memory: 15120kb

input:

500 124750
24 277 336609231
189 48 329957751
130 307 334562839
150 5 350299699
130 306 338627627
391 416 326018518
297 489 326045958
156 153 333330346
154 482 339034861
492 259 323077166
370 5 333649013
258 204 324978731
64 228 352908115
58 244 340587477
429 419 321475204
151 143 325381408
248 38 33...

output:

695755972
1 359
2 359
3 359
4 359
5 359
6 359
7 359
8 359
9 359
10 359
11 359
12 359
13 359
14 359
15 359
16 359
17 359
18 359
19 359
20 359
21 359
22 359
23 359
24 359
25 359
26 359
27 359
28 359
29 359
30 359
31 359
32 359
33 359
34 359
35 359
36 359
37 359
38 359
39 359
40 359
41 359
42 359
43 35...

result:

ok 

Test #14:

score: 0
Accepted
time: 370ms
memory: 15172kb

input:

500 124750
384 14 425038468
192 260 675657326
292 198 23251605
1 463 124292609
231 2 178513186
300 408 50265695
320 78 81387545
90 190 923582754
498 409 916628446
420 166 299413262
23 339 542251129
5 237 493710510
251 6 12885827
444 8 440135613
242 173 686046528
30 301 61808439
264 60 642406301
248 ...

output:

40740713
1 441
441 193
193 459
459 153
153 213
213 246
246 204
2 230
230 193
3 417
417 355
355 9
9 39
39 103
103 213
4 440
440 129
129 372
372 246
5 394
394 320
320 431
431 204
6 161
161 101
101 459
7 161
8 138
138 44
44 185
185 407
407 213
10 129
11 283
283 479
479 213
12 296
296 103
13 120
120 88
...

result:

ok 

Test #15:

score: 0
Accepted
time: 363ms
memory: 15120kb

input:

500 124750
202 447 336741012
92 270 663436926
89 41 309047741
345 240 587182923
14 358 303518613
107 72 624877592
270 468 280136986
256 150 719953302
451 155 767165840
99 256 496809180
24 72 326743318
199 127 228787790
326 143 349499492
326 358 965377787
7 404 903718497
52 100 838914124
219 233 6663...

output:

46749755
1 285
285 203
203 122
122 172
172 408
2 330
330 438
438 408
3 295
295 115
115 417
417 158
158 403
403 95
95 280
280 172
4 85
85 64
64 465
465 487
487 273
273 280
5 182
182 490
490 245
245 471
471 215
215 95
6 111
111 31
31 232
232 229
229 438
7 252
252 253
253 220
220 273
8 100
100 25
25 45...

result:

ok 

Test #16:

score: 0
Accepted
time: 370ms
memory: 15100kb

input:

500 124750
473 261 267443376
438 59 540452305
197 481 350240182
99 51 255230904
235 459 810428481
153 287 364214007
316 333 252023630
141 84 602938702
390 38 840115034
80 121 768116227
188 336 316269065
246 63 532812842
159 9 600703944
39 5 983000839
342 140 197843308
377 410 592004365
15 135 203770...

output:

37971004
1 286
286 142
142 122
122 137
137 192
2 69
69 155
155 192
3 370
370 141
141 181
181 155
4 122
5 246
246 33
33 192
6 356
356 155
7 179
179 181
8 56
56 452
452 269
269 33
9 499
499 227
227 53
53 278
278 122
10 218
218 113
113 105
105 371
371 278
11 166
166 142
12 356
13 105
14 20
20 455
455 3...

result:

ok 

Test #17:

score: 0
Accepted
time: 365ms
memory: 15104kb

input:

500 124750
326 216 865974032
342 145 899173929
326 17 95028303
270 362 420387995
495 164 932329585
69 201 348342984
189 89 860429924
171 314 195039912
302 399 8710790
495 328 336795245
227 164 322999677
49 444 746557
349 7 208544655
134 150 54925387
305 347 75313895
367 143 447473444
485 95 28555430...

output:

41635892
226 291
491 488
488 251
251 250
250 241
241 226
328 291
1 257
257 216
216 211
211 484
484 324
324 256
256 190
190 252
252 291
2 324
3 96
96 375
375 298
298 228
228 324
4 202
202 470
470 190
5 238
238 256
6 183
183 74
74 279
279 289
289 226
7 367
367 195
195 376
376 226
8 76
76 470
9 211
10 ...

result:

ok 

Test #18:

score: 0
Accepted
time: 363ms
memory: 15288kb

input:

500 124750
50 103 169644033
350 25 733427517
360 329 325740461
491 358 863234848
246 109 425224534
3 106 362191273
495 24 283250521
375 458 893528294
364 423 711146313
150 15 835762784
150 331 623176965
405 70 386196999
65 177 211037895
445 279 242692580
340 109 410272265
173 268 334368275
263 447 7...

output:

42973111
1 192
346 93
93 279
279 108
108 1
478 195
195 437
437 393
393 192
2 461
461 405
405 279
3 182
182 166
166 426
426 256
256 156
156 257
257 108
4 26
26 457
457 179
179 333
333 393
5 491
491 178
178 163
163 119
119 340
340 192
6 61
61 71
71 119
7 192
8 279
9 437
10 134
134 470
470 192
11 154
1...

result:

ok 

Test #19:

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

input:

10 45
1 8 852386547
1 6 896725964
1 7 398330288
10 7 745956332
4 3 77447028
7 9 397520615
8 6 802361809
4 7 772673968
1 2 174055957
10 5 103665853
4 9 485247227
4 2 258249623
9 2 728388812
7 8 106246975
8 10 888960723
8 2 598923263
7 6 905994898
4 5 576321126
3 8 770589879
10 1 496876256
1 5 8349896...

output:

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

result:

ok 

Test #20:

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

input:

10 45
2 8 114030772
9 6 370138763
4 1 649979236
9 10 595837331
1 3 398896234
3 4 916893101
7 2 927242800
9 8 85375078
6 4 628048978
10 1 62710986
10 8 198495177
2 9 620688683
3 2 817822965
1 7 475778205
2 6 444985984
7 4 791328882
5 10 714881954
2 4 92374685
9 3 509479385
7 5 472012838
8 6 515456030...

output:

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

result:

ok 

Test #21:

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

input:

10 45
3 2 411603519
2 1 530222805
5 8 401884056
2 8 629138281
9 4 279043576
2 7 355714714
9 1 16302019
2 4 366691234
3 6 641321323
9 2 102923145
5 10 471322247
9 3 276998611
4 5 140929491
10 3 625579125
1 4 525865610
6 7 200122395
7 8 412320889
10 7 215063702
1 6 950279547
5 9 122526015
10 2 4510894...

output:

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

result:

ok 

Test #22:

score: 0
Accepted
time: 225ms
memory: 15224kb

input:

500 499
489 250 911816417
42 183 576360685
413 27 603166565
340 6 740155781
282 267 886335166
202 36 846414216
70 273 536335885
94 400 679118131
186 292 325240258
68 99 356682437
93 324 130056528
202 490 975232337
374 459 608441376
3 217 840906454
40 367 175667143
306 120 471709580
120 215 691146618...

output:

32760257077
211 378
126 45
45 11
11 67
67 467
467 14
14 123
123 244
244 400
400 94
94 447
447 20
20 152
152 463
463 174
174 341
341 439
439 93
93 217
217 3
3 334
334 268
268 471
471 465
465 121
121 83
83 211
352 427
427 229
229 212
212 464
464 209
209 379
379 479
479 173
173 306
306 365
365 24
24 45...

result:

ok 

Test #23:

score: 0
Accepted
time: 213ms
memory: 15108kb

input:

499 498
115 438 632124054
265 323 590854058
205 408 640558868
144 190 863488857
496 129 397594428
70 111 349959309
263 29 495455138
401 358 394611413
489 425 957892531
142 332 389151686
133 38 15576349
228 379 52447487
320 283 49471342
437 390 652438631
51 37 41057275
473 6 599793848
313 450 3796515...

output:

33794638693
63 279
103 308
308 494
494 333
333 263
263 3
3 321
321 417
417 209
209 152
152 334
334 361
361 138
138 207
207 471
471 164
164 372
372 439
439 356
356 145
145 73
73 66
66 322
322 423
423 76
76 305
305 142
142 332
332 63
416 186
186 317
317 88
88 377
377 375
375 268
268 262
262 213
213 36...

result:

ok 

Test #24:

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

input:

3 2
2 3 255741785
2 1 160496570

output:

416238355
1 2
3 2

result:

ok 

Test #25:

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

input:

100 99
65 34 441414148
22 95 527003384
74 85 80656954
10 64 893508913
32 42 110880114
91 74 519216315
68 70 233703686
20 92 370689334
39 48 209550382
52 1 846701392
94 10 214278326
84 99 574671008
21 43 936333553
92 75 889270962
55 69 989214957
67 83 121514850
21 87 989248231
2 26 935422061
80 65 95...

output:

14316191893
1 52
52 25
25 7
7 97
97 20
20 92
92 51
51 21
21 43
2 68
68 33
33 75
75 92
3 22
22 89
89 99
99 84
84 10
10 94
94 28
28 54
54 12
12 9
9 80
80 43
4 35
35 34
34 65
65 80
5 75
6 40
40 63
63 49
49 91
91 31
31 2
8 26
26 2
11 67
67 25
13 45
45 11
14 72
72 80
15 81
81 22
16 40
17 67
18 34
19 47
4...

result:

ok 

Test #26:

score: 0
Accepted
time: 283ms
memory: 15096kb

input:

500 499
84 429 1000000000
221 147 1000000000
32 342 1000000000
215 314 1000000000
119 179 1000000000
108 435 1000000000
387 152 1000000000
205 212 1000000000
269 394 1000000000
275 474 1000000000
448 350 1000000000
359 365 1000000000
296 402 1000000000
224 73 1000000000
109 499 1000000000
349 351 10...

output:

499000000000
1 394
394 269
269 91
91 319
319 380
380 411
411 28
28 120
120 18
18 137
137 298
298 459
459 240
240 272
272 495
495 407
407 487
487 94
94 184
184 466
466 426
426 151
151 43
43 443
443 352
352 273
273 188
188 218
218 152
152 387
387 439
439 168
168 307
307 55
55 265
265 310
310 133
133 2...

result:

ok 

Test #27:

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

input:

2 1
1 2 1000000000

output:

1000000000
2 1

result:

ok 

Test #28:

score: 0
Accepted
time: 356ms
memory: 15216kb

input:

500 112375
215 411 405573103
483 202 429632204
49 152 641147973
424 223 313115211
102 480 37625732
135 498 287528728
11 372 755681501
60 331 159823988
227 78 518118983
185 167 755911454
130 269 191205737
55 152 445920241
152 407 834003692
113 185 512296966
396 177 680449942
371 473 23006247
125 47 6...

output:

46093603
1 477
477 208
208 458
458 217
217 108
108 38
38 162
162 18
2 401
401 497
497 108
3 60
60 217
4 162
5 142
142 231
231 450
450 52
52 162
6 374
374 294
294 108
7 427
427 56
56 416
416 108
8 105
105 479
479 96
96 334
334 18
9 355
355 302
302 374
10 60
11 255
255 4
12 6
13 359
359 110
110 4
14 2...

result:

ok 

Test #29:

score: 0
Accepted
time: 299ms
memory: 15228kb

input:

500 62254
428 55 673055918
215 410 148588730
75 376 213490326
263 232 596161560
64 398 839662234
170 473 426273328
221 214 725162854
8 382 656895268
407 251 472418635
285 64 454705591
238 432 602541117
340 392 788352611
68 108 508348843
328 297 694088955
25 51 861300749
255 242 119135283
270 496 758...

output:

93031648
1 82
82 364
364 153
153 209
2 269
269 56
56 240
240 209
3 35
35 165
165 153
4 407
407 88
88 483
483 385
385 73
73 209
5 189
189 151
151 19
19 214
214 485
485 364
6 319
319 22
22 482
482 101
101 336
336 73
7 406
406 238
238 155
155 121
121 495
495 364
8 254
254 73
9 241
241 89
89 328
328 77
...

result:

ok 

Test #30:

score: 0
Accepted
time: 266ms
memory: 15028kb

input:

500 24926
202 335 87826903
145 367 249043133
296 266 234995839
400 252 908643196
247 365 670330835
365 312 417431159
400 490 824592807
403 123 901931953
226 363 926551074
453 488 215017578
144 225 960418940
205 69 506382361
489 133 278874199
468 146 198386148
222 216 496678072
349 342 300581775
158 ...

output:

195696372
1 245
245 177
177 305
305 247
247 148
148 292
292 346
346 35
35 144
2 3
3 398
398 10
10 144
4 233
233 55
55 429
429 56
56 292
5 471
471 351
351 144
6 419
419 157
157 122
122 351
7 387
387 285
285 343
343 35
8 70
70 34
34 309
309 181
181 163
163 471
9 109
109 220
220 54
54 86
86 63
63 346
1...

result:

ok 

Test #31:

score: 0
Accepted
time: 248ms
memory: 15132kb

input:

500 7425
81 342 810238489
27 14 908239231
273 373 287258613
253 432 563166711
278 199 932063977
373 100 814478323
426 105 374600399
60 251 16098593
166 201 655716982
456 168 66673197
30 121 595035829
170 431 817407488
173 126 660336891
226 220 24714054
386 278 322211588
16 12 54069814
406 341 169888...

output:

635007062
314 392
366 99
99 281
281 115
115 145
145 239
239 16
16 38
38 487
487 226
226 314
62 65
65 493
493 125
125 284
284 406
406 213
213 52
52 392
1 101
101 261
261 296
296 405
405 447
447 452
452 220
220 226
2 304
304 395
395 52
3 384
384 450
450 52
4 193
193 406
5 409
409 3
6 377
377 87
87 459...

result:

ok 

Test #32:

score: 0
Accepted
time: 233ms
memory: 15100kb

input:

500 3780
366 95 394951594
6 366 802428678
87 202 504216135
478 261 621604711
108 261 136061971
119 31 234424551
265 405 267843581
403 307 789242971
80 208 9360049
23 151 536803184
35 208 113064121
17 442 868266027
419 438 844536791
32 31 683803313
420 211 824670471
13 227 45871642
312 124 865431657
...

output:

1442276057
1 8
8 455
455 182
182 248
248 416
416 459
459 467
467 97
2 307
307 279
279 154
154 115
115 97
3 262
262 467
4 470
470 171
171 329
329 462
462 385
385 103
103 195
195 297
297 459
5 471
471 416
6 419
419 341
341 97
7 470
9 88
88 246
246 262
10 246
11 399
399 195
12 289
289 457
457 3
13 28
2...

result:

ok 

Test #33:

score: 0
Accepted
time: 241ms
memory: 15108kb

input:

499 7413
453 253 365177445
73 82 676484140
472 167 572434873
292 454 881725762
351 448 816134721
11 74 99817392
3 152 899527423
343 267 283437304
317 368 658958165
302 12 545721809
25 252 826963352
238 102 653491178
49 405 499572039
7 95 632608197
337 427 400888272
291 307 41716753
97 222 154670567
...

output:

649053601
17 109
192 141
141 75
75 59
59 17
251 270
270 33
33 225
225 109
1 267
267 156
156 386
386 225
2 47
47 81
81 131
131 454
454 124
124 156
3 391
391 329
329 334
334 109
4 140
140 75
5 346
346 329
6 89
89 55
55 59
7 6
8 452
452 346
9 248
248 131
10 362
362 275
275 45
45 329
11 487
487 211
211 ...

result:

ok 

Test #34:

score: 0
Accepted
time: 228ms
memory: 15180kb

input:

500 998
357 37 615878375
355 220 158580531
459 81 359502925
464 212 517883144
423 87 670629712
144 226 399414281
138 360 72111835
317 390 728659672
445 53 690042117
451 15 711431052
279 52 747492925
292 177 846356995
468 170 50253940
282 237 706952552
336 337 720468410
259 156 356422088
170 428 7889...

output:

4441235878
247 443
178 123
123 230
230 279
279 52
52 247
233 464
464 212
212 229
229 427
427 474
474 443
1 55
55 247
2 247
3 152
152 141
141 223
223 2
4 335
335 25
25 299
299 117
117 443
5 241
241 336
336 224
224 272
272 55
6 285
285 272
7 333
333 32
32 461
461 113
113 258
258 272
8 53
53 101
101 48...

result:

ok 

Test #35:

score: 0
Accepted
time: 229ms
memory: 15176kb

input:

500 1489
251 283 336346626
268 345 197720766
140 346 368809904
481 154 810739392
283 82 466080515
316 88 398780699
337 220 873542149
220 300 789681082
495 292 836172158
122 274 642176095
310 404 583796616
78 397 116645447
112 95 526153997
252 242 538439401
199 155 108445198
221 142 170150171
14 123 ...

output:

3335034921
1 140
140 346
346 294
2 247
247 443
443 474
474 427
427 319
319 346
3 152
152 141
141 319
4 133
133 484
484 494
494 346
5 251
251 89
89 271
271 270
270 294
6 285
285 272
272 258
258 494
7 333
333 32
32 494
8 53
53 462
462 387
387 434
434 154
154 319
9 491
491 154
10 179
179 73
73 304
304 ...

result:

ok 

Test #36:

score: 0
Accepted
time: 235ms
memory: 15076kb

input:

500 1983
390 46 325419612
352 173 956124303
21 49 87118967
434 293 181309943
1 322 966816097
374 363 405786700
387 462 663285952
221 431 114079525
386 364 919848935
364 377 588992539
64 111 763731869
239 380 467883942
37 62 914591429
299 194 812634844
41 352 774415821
166 259 622646113
439 393 67889...

output:

2538508929
1 39
39 325
325 91
2 247
247 88
88 166
166 35
35 91
3 152
152 343
343 397
397 98
98 35
4 158
158 105
105 221
221 142
142 325
5 22
22 35
6 110
110 49
49 402
402 325
7 278
278 91
8 53
53 101
101 486
486 397
9 33
33 78
78 397
10 91
11 159
159 91
12 33
13 111
111 35
14 263
263 85
85 205
205 3...

result:

ok 

Test #37:

score: 0
Accepted
time: 233ms
memory: 15172kb

input:

500 2472
26 259 300350996
483 172 113333131
223 2 360381923
291 42 637617104
350 300 449910518
26 163 611186507
472 365 189750058
343 110 448614498
28 77 642365375
65 5 815239874
76 259 900880611
371 17 711438797
489 79 89712650
476 225 198266248
277 357 648844147
29 235 887755827
343 90 437780951
1...

output:

1987249621
1 454
454 286
286 166
166 35
35 91
2 247
247 55
55 272
272 285
285 297
297 325
325 91
3 152
152 343
343 397
397 98
98 35
4 305
305 432
432 50
50 485
485 198
198 98
5 22
22 35
6 285
7 240
240 221
221 142
142 325
8 53
53 101
101 486
486 397
9 121
121 83
83 24
24 112
112 289
289 325
10 91
11...

result:

ok 

Test #38:

score: 0
Accepted
time: 230ms
memory: 15044kb

input:

500 2957
465 121 968799590
205 395 23464769
131 186 292946801
138 399 632201011
404 23 254378437
13 40 610881364
389 61 43222378
118 164 621828299
380 310 876201865
393 260 582208954
360 43 303515652
278 449 587854697
204 107 450595359
312 165 693035862
239 311 426200604
368 347 875502366
456 215 23...

output:

1720003538
1 454
454 389
389 477
477 424
424 272
272 285
2 247
247 55
55 272
3 51
51 116
116 111
111 285
4 259
259 452
452 280
280 417
417 285
5 272
6 285
7 157
157 499
499 199
199 314
314 258
258 272
8 293
293 421
421 24
24 83
83 262
262 272
9 121
121 83
10 194
194 412
412 441
441 55
11 159
159 91
...

result:

ok 

Test #39:

score: 0
Accepted
time: 237ms
memory: 15048kb

input:

500 3445
260 191 387557630
460 96 437785661
414 157 788571963
467 204 422896812
275 38 82565240
154 319 186508009
400 94 679118131
347 180 401381454
98 147 462666191
112 84 164496728
122 77 698092305
217 295 71771915
430 403 650087807
156 396 553244458
357 16 110311943
467 130 833512070
38 352 62662...

output:

1483608654
379 454
374 234
234 101
101 16
16 114
114 41
41 80
80 335
335 25
25 379
108 260
260 71
71 454
1 454
2 247
247 55
55 441
441 329
329 299
299 25
3 51
51 116
116 80
4 335
5 272
272 424
424 477
477 389
389 454
6 110
110 49
49 248
248 232
232 149
149 151
151 276
276 468
468 80
7 157
157 499
49...

result:

ok 

Test #40:

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

input:

17 30
16 4 554374432
9 2 215208399
5 3 513409742
6 14 506215306
7 13 537124830
16 15 143014337
17 10 816248153
1 7 242153020
6 2 37119022
12 8 137831502
16 11 237336357
9 1 881761968
14 12 318095050
8 1 208032501
6 10 190870607
15 14 346948152
13 3 846045895
3 11 694053968
14 17 419599539
6 5 208704...

output:

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

result:

ok 

Test #41:

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

input:

17 43
4 3 506147731
2 6 37119022
3 5 513409742
6 12 516377635
4 15 675716898
17 11 219922878
7 1 242153020
13 4 133275785
16 3 940198937
8 4 956435856
4 16 554374432
17 14 419599539
14 16 933384890
14 4 298309896
2 12 8225926
5 2 713365483
14 12 318095050
12 8 225374527
17 3 189766466
7 13 537124830...

output:

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

result:

ok 

Test #42:

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

input:

17 56
15 12 174616807
14 12 318095050
4 8 956435856
8 1 208032501
6 14 506215306
7 9 112445395
3 16 940198937
9 1 881761968
15 16 143014337
17 10 816248153
5 3 513409742
13 5 110880114
12 8 225374527
2 16 286986530
14 16 441504628
7 1 242153020
6 10 190870607
2 9 215208399
6 13 116383718
15 14 34694...

output:

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

result:

ok 

Test #43:

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

input:

17 65
6 17 197550393
15 14 346948152
17 5 893508913
12 15 174616807
7 16 324584324
9 12 973708325
16 11 237336357
3 11 436207833
3 1 389872647
7 2 580944484
13 7 537124830
11 17 833923911
15 4 675716898
14 17 419599539
12 11 905778941
14 4 298309896
6 2 37119022
16 15 143014337
11 7 519216315
4 5 45...

output:

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

result:

ok 

Test #44:

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

input:

10 44
7 1 517400951
10 3 471593384
1 3 547761444
7 8 791370537
4 5 369007550
2 5 564183890
3 9 965720849
2 6 130399919
6 4 756732023
9 8 902540844
6 9 760427451
10 5 162352859
3 2 908640945
10 8 531885690
10 2 113869678
9 5 196323620
5 1 460453279
1 10 660682369
1 2 359263377
8 5 112464084
6 8 17956...

output:

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

result:

ok 

Test #45:

score: 0
Accepted
time: 345ms
memory: 15104kb

input:

500 124750
473 98 225
91 199 248
16 76 249
203 221 249
431 332 256
184 406 264
324 101 263
197 10 229
275 267 239
240 23 260
461 74 252
169 242 266
197 49 253
70 307 250
33 235 235
429 201 249
470 303 236
239 250 235
377 461 247
46 47 258
337 204 245
162 287 256
44 256 239
55 32 257
65 273 252
398 2...

output:

546
1 184
2 184
3 184
4 184
5 184
6 184
7 184
8 184
9 184
10 184
11 184
12 184
13 184
14 184
15 184
16 184
17 184
18 184
19 184
20 184
21 184
22 184
23 184
24 184
25 184
26 184
27 184
28 184
29 184
30 184
31 184
32 184
33 184
34 184
35 184
36 184
37 184
38 184
39 184
40 184
41 184
42 184
43 184
44 1...

result:

ok 

Test #46:

score: 0
Accepted
time: 361ms
memory: 15124kb

input:

500 124750
304 88 436
94 161 421
447 321 442
404 288 462
137 200 420
195 380 453
451 351 444
402 232 423
344 60 439
286 379 452
149 388 484
468 310 445
6 409 429
130 335 410
265 323 440
146 181 442
398 185 451
336 242 455
303 237 436
441 330 428
314 428 468
97 5 456
45 295 421
231 104 443
360 61 444...

output:

942
1 430
2 430
3 430
4 430
5 430
6 430
7 430
8 430
9 430
10 430
11 430
12 430
13 430
14 430
15 430
16 430
17 430
18 430
19 430
20 430
21 430
22 430
23 430
24 430
25 430
26 430
27 430
28 430
29 430
30 430
31 430
32 430
33 430
34 430
35 430
36 430
37 430
38 430
39 430
40 430
41 430
42 430
43 430
44 4...

result:

ok