QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#62469#4329. Mjcelin60 784ms73512kbC++144.6kb2022-11-19 08:38:342022-11-19 08:38:37

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 4ms
memory: 18520kb

input:

2 0
1
1 2

output:

-1

result:

ok single line: '-1'

Test #2:

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

input:

2 1
1 2
1
1 2

output:

-1

result:

ok single line: '-1'

Test #3:

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

input:

2 2
1 2
1 2
1
1 2

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 26ms
memory: 46708kb

input:

286524 0
1
202914 240681

output:

-1

result:

ok single line: '-1'

Test #5:

score: 0
Accepted
time: 95ms
memory: 33620kb

input:

700 244650
1 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 ...

output:

1374

result:

ok single line: '1374'

Test #6:

score: 0
Accepted
time: 168ms
memory: 56648kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

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

output:

276660

result:

ok single line: '276660'

Test #8:

score: 0
Accepted
time: 160ms
memory: 41172kb

input:

100 296786
95 34
21 83
7 5
38 11
99 60
10 53
61 42
54 34
49 63
83 44
76 74
39 52
24 58
16 65
73 100
92 82
48 42
68 88
81 83
46 6
68 72
15 81
36 74
62 71
45 55
58 13
9 96
23 41
83 72
47 100
55 26
79 68
74 60
73 72
80 94
89 36
83 26
31 41
39 73
47 41
72 99
37 46
93 38
74 71
25 9
68 40
6 78
86 77
50 29...

output:

169

result:

ok single line: '169'

Test #9:

score: 0
Accepted
time: 145ms
memory: 40880kb

input:

100 272289
23 78
32 44
98 73
46 98
31 54
27 51
9 8
42 27
2 50
53 68
87 81
34 39
40 7
68 29
68 91
70 22
35 46
93 94
27 3
76 61
26 96
86 24
18 55
80 91
94 14
45 53
39 76
36 67
20 47
11 21
49 50
62 38
96 48
35 37
28 84
45 77
96 32
18 58
15 28
9 46
55 36
32 66
29 38
93 46
44 72
99 91
80 19
35 75
31 43
5...

output:

96

result:

ok single line: '96'

Test #10:

score: 0
Accepted
time: 251ms
memory: 41112kb

input:

1000 296203
12 969
240 870
378 531
817 233
423 12
613 431
767 403
402 523
873 479
927 556
147 544
702 761
403 713
819 620
22 427
353 290
483 974
875 334
54 219
268 66
293 983
677 128
301 323
183 71
441 225
531 394
946 897
514 346
674 985
122 29
333 352
275 381
571 765
661 939
283 320
147 433
114 271...

output:

2244

result:

ok single line: '2244'

Test #11:

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

input:

1000 270311
365 502
500 496
8 134
317 143
14 219
878 419
138 249
139 85
396 346
495 167
316 879
374 951
735 39
968 700
702 573
136 899
137 667
951 548
554 703
944 387
630 695
565 825
640 466
766 941
376 804
835 984
105 170
80 522
68 946
491 650
210 861
926 971
981 186
670 244
582 874
795 907
47 759
...

output:

1412

result:

ok single line: '1412'

Test #12:

score: 0
Accepted
time: 367ms
memory: 41584kb

input:

10000 293140
2988 208
4946 6337
4431 7489
8320 4986
5834 2248
252 1981
7093 7606
2656 1692
2637 884
1504 6854
6839 9534
8167 40
3361 5122
8909 8127
1982 6126
307 7218
8777 2919
7275 9178
5409 7146
1315 5426
4137 1422
7788 3734
5840 6742
1827 4419
8261 4341
1055 6178
2836 5132
656 6504
565 6011
7655 ...

output:

8565

result:

ok single line: '8565'

Test #13:

score: 0
Accepted
time: 327ms
memory: 41296kb

input:

10000 275408
684 195
6648 4633
1942 7250
9263 4203
1052 4855
2258 128
8964 4874
8262 9419
929 8508
8898 7300
7138 1088
5179 8940
7854 8572
5877 1651
7369 6324
6726 205
9701 1168
9886 3164
7782 1580
252 7590
9213 8183
4110 3447
1898 3188
2041 1117
8641 840
1552 7128
7749 5996
4832 557
7834 4798
450 4...

output:

11328

result:

ok single line: '11328'

Test #14:

score: 0
Accepted
time: 427ms
memory: 42960kb

input:

100000 274625
44623 74007
87341 26332
8644 53375
72362 1458
35049 91877
3397 90073
29545 3343
8253 95697
72597 13722
37285 28384
67601 60610
98367 94424
48154 85275
91256 226
18988 52124
14798 55205
90729 48539
68434 76815
95775 16072
45606 76458
56315 2082
80128 13522
94320 11628
22337 30991
70296 ...

output:

135459

result:

ok single line: '135459'

Test #15:

score: 0
Accepted
time: 468ms
memory: 44256kb

input:

100000 293331
60736 23755
85945 82430
89300 96577
17916 97262
75860 45346
75168 60906
60736 77554
79404 64163
38805 72203
34036 3504
66193 29846
90557 5852
72005 85708
47160 37286
49702 67986
44628 25629
53059 34759
99327 942
61447 35834
18031 94911
72288 21791
93913 31940
53840 91779
47015 3191
624...

output:

193492

result:

ok single line: '193492'

Test #16:

score: 0
Accepted
time: 329ms
memory: 60308kb

input:

300000 285418
276579 231959
197734 261139
109890 2415
44704 92925
60389 287293
66601 153942
95832 95490
109241 161767
161711 66380
204436 241954
160492 102681
74251 161673
289910 1763
45429 201954
65691 63010
88356 279779
103603 112278
297413 225735
67979 228951
292780 261161
33545 33035
51904 90032...

output:

176354

result:

ok single line: '176354'

Test #17:

score: 0
Accepted
time: 313ms
memory: 60748kb

input:

300000 295465
244084 53671
177414 16310
33298 108466
245594 82624
278004 159007
7487 91780
246700 91346
215986 33524
63636 74973
261740 275300
9750 79248
150612 215341
165272 259725
295345 242134
126723 63168
250073 50175
211784 14013
232403 11828
34982 60072
109104 299575
247039 111841
77750 228162...

output:

-1

result:

ok single line: '-1'

Test #18:

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

input:

131072 262142
1 2
1 2
3 4
3 4
2 3
2 3
5 6
5 6
7 8
7 8
6 7
6 7
4 5
4 5
9 10
9 10
11 12
11 12
10 11
10 11
13 14
13 14
15 16
15 16
14 15
14 15
12 13
12 13
8 9
8 9
17 18
17 18
19 20
19 20
18 19
18 19
21 22
21 22
23 24
23 24
22 23
22 23
20 21
20 21
25 26
25 26
27 28
27 28
26 27
26 27
29 30
29 30
31 32
31...

output:

262142

result:

ok single line: '262142'

Test #19:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #20:

score: 0
Accepted
time: 137ms
memory: 37452kb

input:

30000 270599
51 1
101 1
151 51
201 51
251 201
301 51
351 51
401 351
451 351
501 101
551 401
601 1
651 401
701 251
751 701
801 451
851 201
901 751
951 1
1001 951
1051 651
1101 351
1151 951
1201 651
1251 901
1301 751
1351 1
1401 401
1451 151
1501 951
1551 451
1601 301
1651 1101
1701 451
1751 1501
1801...

output:

-1

result:

ok single line: '-1'

Test #21:

score: 0
Accepted
time: 142ms
memory: 45660kb

input:

136463 272924
2 1
2 1
3 2
3 2
4 2
4 2
5 1
5 1
6 4
6 4
7 1
7 1
8 2
8 2
9 3
9 3
10 7
10 7
11 1
11 1
12 1
12 1
13 9
13 9
14 2
14 2
15 12
15 12
16 1
16 1
17 16
17 16
18 17
18 17
19 12
19 12
20 12
20 12
21 5
21 5
22 18
22 18
23 13
23 13
24 13
24 13
25 14
25 14
26 2
26 2
27 7
27 7
28 20
28 20
29 4
29 4
30...

output:

186464

result:

ok single line: '186464'

Test #22:

score: 0
Accepted
time: 97ms
memory: 56040kb

input:

143822 287642
2 1
2 1
3 2
3 2
4 3
4 3
5 4
5 4
6 5
6 5
7 6
7 6
8 7
8 7
9 8
9 8
10 9
10 9
11 10
11 10
12 11
12 11
13 12
13 12
14 13
14 13
15 14
15 14
16 15
16 15
17 16
17 16
18 17
18 17
19 18
19 18
20 19
20 19
21 20
21 20
22 21
22 21
23 22
23 22
24 23
24 23
25 24
25 24
26 25
26 25
27 26
27 26
28 27
28...

output:

274530

result:

ok single line: '274530'

Subtask #2:

score: 20
Accepted

Test #23:

score: 20
Accepted
time: 1ms
memory: 18688kb

input:

2 2
1 2
1 2
1
1 2

output:

2

result:

ok single line: '2'

Test #24:

score: 0
Accepted
time: 101ms
memory: 46208kb

input:

282511 0
299916
203511 263473
33 36199
85417 282256
41463 66702
26089 112045
52624 109596
97631 189221
112098 264315
152230 239106
118434 88509
193593 148199
57764 125288
248092 64862
7738 150987
189425 258219
117900 129173
157845 121684
39664 265329
55969 219916
226232 202281
273560 226801
88551 26...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 299916 lines

Test #25:

score: 0
Accepted
time: 274ms
memory: 52616kb

input:

131072 262142
1 2
1 2
3 4
3 4
2 3
2 3
5 6
5 6
7 8
7 8
6 7
6 7
4 5
4 5
9 10
9 10
11 12
11 12
10 11
10 11
13 14
13 14
15 16
15 16
14 15
14 15
12 13
12 13
8 9
8 9
17 18
17 18
19 20
19 20
18 19
18 19
21 22
21 22
23 24
23 24
22 23
22 23
20 21
20 21
25 26
25 26
27 28
27 28
26 27
26 27
29 30
29 30
31 32
31...

output:

65534
262140
262142
131066
90106
65532
196604
131070
131068
196604
262140
262142
262142
262142
262140
262142
262142
262142
65534
262140
131070
131068
32762
49148
262142
262142
65534
262142
262142
131070
131070
262142
262142
262140
262142
262140
262140
65534
262142
262138
135164
262142
262142
262142
...

result:

ok 283080 lines

Test #26:

score: 0
Accepted
time: 685ms
memory: 46932kb

input:

143262 286522
2 1
2 1
3 2
3 2
4 3
4 3
5 2
5 2
6 1
6 1
7 4
7 4
8 4
8 4
9 8
9 8
10 4
10 4
11 9
11 9
12 1
12 1
13 2
13 2
14 1
14 1
15 3
15 3
16 4
16 4
17 1
17 1
18 2
18 2
19 8
19 8
20 14
20 14
21 1
21 1
22 4
22 4
23 11
23 11
24 11
24 11
25 16
25 16
26 6
26 6
27 8
27 8
28 10
28 10
29 19
29 19
30 15
30 1...

output:

243704
138692
259300
170980
230262
221118
284100
253140
207246
81998
167430
226110
171158
275498
143732
104800
268692
103034
283436
160896
64300
155868
268492
234180
99974
258846
257454
201076
235588
274206
103822
227234
258742
274094
163676
158910
104054
275814
201386
223022
232914
278242
214212
72...

result:

ok 284324 lines

Test #27:

score: 0
Accepted
time: 729ms
memory: 48496kb

input:

149506 299010
2 1
2 1
3 2
3 2
4 1
4 1
5 4
5 4
6 5
6 5
7 5
7 5
8 5
8 5
9 6
9 6
10 6
10 6
11 3
11 3
12 2
12 2
13 12
13 12
14 3
14 3
15 1
15 1
16 11
16 11
17 5
17 5
18 16
18 16
19 8
19 8
20 13
20 13
21 16
21 16
22 1
22 1
23 5
23 5
24 14
24 14
25 21
25 21
26 10
26 10
27 26
27 26
28 17
28 17
29 5
29 5
30...

output:

126372
184008
130688
216656
200698
277824
157364
293054
147204
90734
183888
261544
48536
200672
233614
100642
230388
282434
141194
193866
111810
216344
273724
277738
20248
294630
73670
241736
265510
238504
236590
112390
258606
198914
161768
225374
272210
96384
248092
193734
112206
230950
210078
1681...

result:

ok 286601 lines

Test #28:

score: 0
Accepted
time: 645ms
memory: 45876kb

input:

138330 276658
2 1
2 1
3 2
3 2
4 3
4 3
5 1
5 1
6 2
6 2
7 6
7 6
8 7
8 7
9 4
9 4
10 1
10 1
11 7
11 7
12 5
12 5
13 10
13 10
14 5
14 5
15 8
15 8
16 8
16 8
17 5
17 5
18 17
18 17
19 4
19 4
20 16
20 16
21 2
21 2
22 14
22 14
23 17
23 17
24 19
24 19
25 11
25 11
26 7
26 7
27 5
27 5
28 21
28 21
29 25
29 25
30 4...

output:

271092
270266
247406
224086
224788
177734
268764
258366
260418
191882
160972
128138
176694
232406
228618
193744
241546
60258
169824
236956
32258
180052
251726
226304
94000
80438
187174
242122
266710
172962
275490
204436
233174
199674
115448
176782
166706
275638
97914
201624
253330
249894
252344
1313...

result:

ok 275339 lines

Test #29:

score: 0
Accepted
time: 680ms
memory: 48056kb

input:

148393 296784
2 1
2 1
3 1
3 1
4 1
4 1
5 4
5 4
6 1
6 1
7 1
7 1
8 3
8 3
9 1
9 1
10 9
10 9
11 6
11 6
12 2
12 2
13 7
13 7
14 8
14 8
15 6
15 6
16 8
16 8
17 6
17 6
18 9
18 9
19 12
19 12
20 16
20 16
21 9
21 9
22 16
22 16
23 17
23 17
24 9
24 9
25 13
25 13
26 6
26 6
27 16
27 16
28 5
28 5
29 19
29 19
30 22
30...

output:

162314
266916
234100
259698
261364
261244
87300
158144
292360
209656
296436
152934
109548
239472
86604
282858
281198
182084
154048
216164
288156
159408
121264
192406
168696
202852
251708
64516
167480
261154
290986
131508
164242
97022
279326
228156
53852
293826
206386
213218
107666
109112
175964
2210...

result:

ok 278983 lines

Test #30:

score: 0
Accepted
time: 683ms
memory: 45712kb

input:

136144 272286
2 1
2 1
3 2
3 2
4 1
4 1
5 2
5 2
6 5
6 5
7 5
7 5
8 4
8 4
9 8
9 8
10 3
10 3
11 6
11 6
12 3
12 3
13 7
13 7
14 2
14 2
15 2
15 2
16 7
16 7
17 5
17 5
18 1
18 1
19 9
19 9
20 11
20 11
21 14
21 14
22 19
22 19
23 18
23 18
24 8
24 8
25 10
25 10
26 10
26 10
27 2
27 2
28 19
28 19
29 9
29 9
30 20
30...

output:

173036
244354
261170
242596
169974
262894
222572
233872
212394
218198
244058
254366
199332
177626
9160
264988
33570
116578
179736
163786
191906
63066
148194
255536
119578
106780
214876
195670
249194
226530
233962
219002
215724
181416
154480
254588
153998
114734
235500
257740
137806
236204
218402
110...

result:

ok 285431 lines

Test #31:

score: 0
Accepted
time: 703ms
memory: 48000kb

input:

148102 296202
2 1
2 1
3 2
3 2
4 1
4 1
5 4
5 4
6 2
6 2
7 4
7 4
8 6
8 6
9 2
9 2
10 4
10 4
11 1
11 1
12 7
12 7
13 6
13 6
14 10
14 10
15 6
15 6
16 7
16 7
17 9
17 9
18 15
18 15
19 9
19 9
20 18
20 18
21 12
21 12
22 4
22 4
23 12
23 12
24 17
24 17
25 19
25 19
26 11
26 11
27 19
27 19
28 23
28 23
29 18
29 18
...

output:

286674
289806
190192
267264
150966
237022
204114
266250
265372
246570
240690
151438
264772
247546
174884
260114
236976
232560
224592
97318
290680
284692
66988
280030
83922
265662
135508
197924
170488
111168
198650
95790
108394
129586
145938
293576
231004
275172
273336
282194
296132
264346
233524
288...

result:

ok 279989 lines

Test #32:

score: 0
Accepted
time: 705ms
memory: 45512kb

input:

135155 270308
2 1
2 1
3 2
3 2
4 2
4 2
5 2
5 2
6 1
6 1
7 1
7 1
8 3
8 3
9 2
9 2
10 1
10 1
11 3
11 3
12 10
12 10
13 6
13 6
14 2
14 2
15 4
15 4
16 3
16 3
17 2
17 2
18 7
18 7
19 7
19 7
20 10
20 10
21 4
21 4
22 7
22 7
23 20
23 20
24 9
24 9
25 23
25 23
26 19
26 19
27 2
27 2
28 27
28 27
29 20
29 20
30 21
30...

output:

139090
233160
159888
87110
183310
268560
260806
246980
192900
208248
232106
51752
34360
264832
223378
236612
42998
256620
75092
104964
167878
168338
203256
197720
233884
105312
200512
258278
202358
130266
227448
203206
230338
29402
138246
217456
209670
190216
148026
180232
193458
120586
154762
23230...

result:

ok 299524 lines

Test #33:

score: 0
Accepted
time: 285ms
memory: 56632kb

input:

146570 293138
2 1
2 1
3 2
3 2
4 3
4 3
5 4
5 4
6 5
6 5
7 6
7 6
8 7
8 7
9 8
9 8
10 9
10 9
11 10
11 10
12 11
12 11
13 12
13 12
14 13
14 13
15 14
15 14
16 15
16 15
17 16
17 16
18 17
18 17
19 18
19 18
20 19
20 19
21 20
21 20
22 21
22 21
23 22
23 22
24 23
24 23
25 24
25 24
26 25
26 25
27 26
27 26
28 27
28...

output:

144984
185748
243868
170994
65896
207898
222942
77272
44082
200906
279478
98516
261134
238212
179556
257264
213240
269036
209472
159042
228276
171164
197616
242158
127226
181092
150422
190658
224386
236044
179386
266362
164056
98348
120534
33412
250062
128978
183590
214502
240166
224804
251178
10308...

result:

ok 278963 lines

Subtask #3:

score: 30
Accepted

Test #34:

score: 30
Accepted
time: 6ms
memory: 18712kb

input:

2 0
1
1 2

output:

-1

result:

ok single line: '-1'

Test #35:

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

input:

2 1
1 2
1
1 2

output:

-1

result:

ok single line: '-1'

Test #36:

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

input:

2 2
1 2
1 2
1
1 2

output:

2

result:

ok single line: '2'

Test #37:

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

input:

4775 0
272121
3382 4011
1390 580
2440 2719
4264 2087
4280 90
600 195
990 1184
246 447
2105 3318
143 695
2182 2164
3100 1030
1330 1690
3230 2353
2822 4362
115 3657
2669 4650
1238 1922
1983 2640
1354 1463
3310 2802
2104 1313
750 2171
2601 3618
3727 3904
1463 1230
1060 4265
1853 3431
4472 99
4661 682
3...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 272121 lines

Test #38:

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

input:

100 4950
1 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...

output:

100
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...

result:

ok 4950 lines

Test #39:

score: 0
Accepted
time: 296ms
memory: 19336kb

input:

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

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 285901 lines

Test #40:

score: 0
Accepted
time: 119ms
memory: 19600kb

input:

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

output:

4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
4611
...

result:

ok 271655 lines

Test #41:

score: 0
Accepted
time: 161ms
memory: 18964kb

input:

100 4947
95 34
21 83
7 5
38 11
99 60
10 53
61 42
54 34
49 63
83 44
76 74
39 52
24 58
16 65
73 100
92 82
48 42
68 88
81 83
46 6
68 72
15 81
36 74
62 71
45 55
58 13
9 96
23 41
83 72
47 100
55 26
79 68
74 60
73 72
80 94
89 36
83 26
31 41
39 73
47 41
72 99
37 46
93 38
74 71
25 9
68 40
6 78
86 77
50 29
5...

output:

128
217
132
150
127
176
217
120
150
384
392
61
173
171
115
110
110
106
110
108
77
150
82
82
240
82
173
110
61
96
115
174
82
80
149
174
140
113
77
166
89
64
166
190
150
96
167
82
171
86
110
174
160
140
127
149
108
125
96
86
82
129
217
176
108
110
110
90
160
149
190
140
174
171
240
108
113
105
78
166
...

result:

ok 292897 lines

Test #42:

score: 0
Accepted
time: 149ms
memory: 18904kb

input:

100 4538
23 78
32 44
98 73
46 98
31 54
27 51
9 8
42 27
2 50
53 68
87 81
34 39
40 7
68 29
68 91
70 22
35 46
93 94
27 3
76 61
26 96
86 24
18 55
80 91
94 14
45 53
39 76
36 67
20 47
11 21
49 50
62 38
96 48
35 37
28 84
45 77
96 32
18 58
15 28
9 46
55 36
32 66
29 38
93 46
44 72
99 91
80 19
35 75
31 43
51 ...

output:

81
141
141
146
162
104
157
135
113
76
113
171
113
146
160
80
113
103
103
109
81
185
106
160
96
160
117
146
131
231
124
157
231
342
170
107
160
111
110
81
117
121
133
112
107
162
106
92
151
117
97
95
157
146
113
126
104
157
92
170
268
104
126
123
95
97
185
131
146
160
170
112
166
154
104
157
107
104
...

result:

ok 275178 lines

Test #43:

score: 0
Accepted
time: 149ms
memory: 18968kb

input:

100 4937
2 97
24 87
38 54
82 24
43 2
62 44
77 41
41 53
88 48
93 56
15 55
71 77
41 72
82 62
3 43
36 29
49 98
88 34
6 22
27 7
30 99
68 13
31 33
19 8
45 23
54 40
95 90
52 35
68 99
13 3
34 36
28 39
58 77
67 94
29 32
15 44
12 28
67 81
7 64
48 7
65 61
14 80
69 4
4 46
91 80
23 99
57 59
27 4
19 45
38 19
48 ...

output:

96
70
187
76
145
121
119
121
92
156
112
172
163
137
145
172
96
84
146
92
112
161
183
235
113
155
218
335
134
233
92
146
233
97
163
301
140
97
172
70
96
161
243
113
146
172
301
125
76
172
77
76
116
233
163
92
233
76
109
213
183
104
301
91
172
233
112
96
161
253
109
183
163
213
221
96
109
156
76
116
7...

result:

ok 298214 lines

Test #44:

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

input:

100 4505
37 51
1 14
32 15
2 22
88 42
14 25
14 9
40 35
50 17
32 88
38 96
74 4
97 70
71 58
14 90
14 67
96 55
56 71
95 39
63 70
57 83
64 47
77 95
38 81
84 99
11 17
8 53
7 95
50 65
21 87
93 98
99 19
67 25
59 88
80 91
5 76
59 35
8 47
17 62
44 50
60 48
15 44
90 88
98 19
93 69
40 71
29 93
32 4
99 65
5 64
1...

output:

111
77
122
99
128
146
280
119
111
153
129
164
78
119
84
78
135
290
404
177
163
260
201
67
130
201
111
230
274
67
113
111
111
97
84
153
202
90
111
215
125
181
215
122
226
290
181
130
163
178
119
97
111
85
67
84
201
135
111
119
84
230
93
144
85
215
234
119
122
119
164
280
111
67
99
97
153
201
82
140
1...

result:

ok 290877 lines

Test #45:

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

input:

100 4886
30 3
50 64
45 75
84 50
59 23
3 20
71 77
27 17
27 9
16 69
69 96
82 1
34 52
90 82
20 62
4 73
88 30
73 92
55 72
14 55
42 15
78 38
59 68
19 45
83 44
11 62
29 52
7 66
6 61
77 81
2 53
62 91
34 32
56 10
34 31
42 12
8 83
86 5
44 63
13 55
74 82
14 20
77 86
84 36
31 76
60 30
88 89
99 33
47 17
88 40
3...

output:

231
125
115
120
136
210
135
108
156
163
136
113
135
182
116
97
125
326
77
103
140
72
92
107
103
77
92
290
289
77
155
125
97
125
116
73
210
117
290
116
120
120
98
108
120
120
116
253
139
169
221
112
81
120
225
120
105
221
120
117
205
140
81
137
116
121
103
77
97
125
253
92
170
289
290
73
103
289
130
...

result:

ok 279113 lines

Test #46:

score: 0
Accepted
time: 145ms
memory: 18844kb

input:

100 4590
7 2
67 47
20 73
93 43
11 49
23 2
90 49
83 95
10 86
89 73
72 11
52 90
79 86
59 17
74 64
68 3
98 12
99 32
78 16
3 76
93 82
42 35
19 32
21 12
87 9
16 72
78 60
49 6
79 48
5 41
63 85
45 72
90 61
7 56
51 95
47 99
68 34
49 24
43 80
40 7
5 37
20 8
48 32
4 8
1 30
93 80
68 91
99 80
47 57
83 62
6 37
7...

output:

186
148
148
104
266
77
90
166
104
111
111
137
126
185
104
138
142
126
178
127
129
218
124
126
118
291
129
200
107
173
143
104
150
92
215
96
77
75
145
113
136
185
148
74
291
127
111
119
205
98
173
266
90
145
75
118
136
104
148
148
84
218
148
178
104
218
111
118
94
77
127
173
96
174
218
77
166
186
74
...

result:

ok 281876 lines

Test #47:

score: 0
Accepted
time: 125ms
memory: 18996kb

input:

100 4577
45 75
88 27
9 54
73 2
36 92
4 91
30 4
9 96
73 14
38 29
68 61
99 95
49 86
92 1
19 53
15 56
91 49
69 77
96 17
46 77
57 3
81 14
95 12
23 31
71 68
50 48
21 82
63 29
15 74
6 71
17 33
87 34
4 98
22 63
99 96
18 77
13 83
55 41
43 46
61 41
79 100
93 18
27 97
31 42
74 43
93 47
3 38
94 47
58 4
16 9
27...

output:

195
193
132
193
180
122
103
94
140
193
210
263
70
85
101
82
134
58
264
117
126
174
228
186
177
90
180
82
126
184
82
98
151
126
158
186
84
126
193
70
382
125
109
132
193
90
170
177
193
85
101
180
117
164
82
145
126
103
94
198
403
177
82
403
105
122
101
177
264
210
87
191
103
87
94
131
403
117
89
382
...

result:

ok 293859 lines

Test #48:

score: 0
Accepted
time: 148ms
memory: 18804kb

input:

100 4889
61 24
86 83
90 97
18 98
76 46
76 61
61 78
80 65
39 73
35 4
67 30
91 6
73 86
48 38
50 68
45 26
54 35
100 1
62 36
19 95
73 22
94 32
54 92
48 4
63 7
69 63
29 88
6 1
79 75
53 82
20 8
60 66
55 51
46 48
52 96
67 1
12 25
12 72
84 33
62 70
59 92
69 25
31 46
63 26
9 38
54 61
7 78
28 7
12 69
63 14
50...

output:

213
174
224
104
223
154
259
293
99
92
153
143
102
223
153
121
131
102
123
106
122
174
102
106
154
174
173
131
155
150
155
123
150
123
92
96
124
141
223
131
147
144
153
117
141
226
139
141
123
122
155
117
155
106
117
103
94
175
63
153
154
102
175
154
121
158
213
103
259
123
122
103
102
123
102
150
14...

result:

ok 298508 lines

Test #49:

score: 0
Accepted
time: 140ms
memory: 18984kb

input:

100 4757
93 78
66 88
37 1
15 31
21 96
23 52
37 54
54 23
69 81
54 35
25 54
97 1
16 68
30 94
35 38
100 76
23 77
98 88
18 31
80 48
92 68
54 26
10 71
12 66
27 19
72 33
18 89
99 9
3 75
2 7
92 74
89 75
9 41
70 100
69 46
99 19
66 36
19 72
82 36
37 6
4 32
69 29
74 47
67 74
33 95
74 18
19 22
46 14
23 21
50 1...

output:

201
88
138
361
135
138
112
145
115
77
134
96
305
124
144
189
88
147
284
127
139
110
361
99
88
88
88
278
194
111
104
88
120
201
99
168
187
185
361
124
187
88
104
139
138
100
88
249
104
305
115
153
115
201
99
112
145
221
91
162
107
95
88
115
194
108
87
189
145
361
150
167
278
145
100
88
145
206
108
28...

result:

ok 281020 lines

Test #50:

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

input:

100 4925
82 18
60 6
12 37
82 28
93 54
3 31
83 31
72 12
22 25
88 92
4 27
51 72
56 87
99 81
43 22
84 17
71 5
78 4
12 21
37 100
83 38
26 77
9 48
97 51
28 95
23 11
48 47
35 15
38 54
73 30
36 54
60 67
83 37
86 63
59 65
83 42
70 41
33 40
14 41
85 8
67 6
74 8
59 70
17 3
49 50
73 14
79 4
26 64
15 45
6 98
35...

output:

175
248
191
116
112
97
116
115
97
88
121
175
108
82
88
196
140
305
82
191
116
112
109
198
116
140
198
151
191
112
140
88
160
129
69
191
125
175
196
216
109
81
340
196
129
116
115
191
82
78
198
277
164
82
103
148
125
186
105
160
140
140
248
210
97
186
88
121
125
82
113
113
69
82
78
164
399
198
88
340...

result:

ok 270119 lines

Test #51:

score: 0
Accepted
time: 116ms
memory: 19064kb

input:

2048 4094
1 2
1 2
3 4
3 4
2 3
2 3
5 6
5 6
7 8
7 8
6 7
6 7
4 5
4 5
9 10
9 10
11 12
11 12
10 11
10 11
13 14
13 14
15 16
15 16
14 15
14 15
12 13
12 13
8 9
8 9
17 18
17 18
19 20
19 20
18 19
18 19
21 22
21 22
23 24
23 24
22 23
22 23
20 21
20 21
25 26
25 26
27 28
27 28
26 27
26 27
29 30
29 30
31 32
31 32
...

output:

4094
4094
2046
2046
4094
4094
4094
4094
4090
3068
1022
3068
4094
4094
1532
2936
2044
1022
2044
4094
4094
4094
2044
2046
4094
4094
4094
3194
4090
4094
4094
2046
4094
4094
4094
3068
4092
4094
510
4094
4094
4094
4092
2046
4094
1020
1276
4090
4094
2046
4094
4094
4094
3066
4094
4094
3068
4092
4090
4094
4...

result:

ok 276698 lines

Test #52:

score: 0
Accepted
time: 108ms
memory: 19096kb

input:

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

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 278840 lines

Test #53:

score: 0
Accepted
time: 181ms
memory: 18940kb

input:

500 4509
51 1
101 1
151 51
201 51
251 201
301 51
351 51
401 351
451 351
11 38
1 34
22 50
29 13
43 2
49 32
17 43
28 37
30 2
15 6
32 15
11 35
15 44
32 10
20 33
28 35
46 18
27 40
47 41
37 10
14 48
22 24
49 34
10 11
27 41
25 16
39 15
36 16
43 42
19 10
40 36
48 32
29 27
41 29
38 1
9 35
44 27
24 4
48 1
25...

output:

2783
2343
-1
-1
2325
1420
3203
-1
-1
-1
-1
-1
-1
964
1889
-1
49
-1
-1
-1
3203
1007
-1
-1
-1
538
-1
-1
986
-1
-1
-1
2344
-1
2309
4102
3695
-1
2316
3675
2799
-1
975
-1
3695
1108
-1
-1
2327
968
1428
-1
3718
1409
3215
-1
-1
968
-1
516
-1
973
3203
94
987
-1
2327
2344
-1
3181
-1
-1
-1
-1
987
2750
4102
233...

result:

ok 274415 lines

Test #54:

score: 0
Accepted
time: 287ms
memory: 19068kb

input:

2274 4546
2 1
2 1
3 2
3 2
4 2
4 2
5 1
5 1
6 4
6 4
7 1
7 1
8 2
8 2
9 3
9 3
10 7
10 7
11 1
11 1
12 1
12 1
13 9
13 9
14 2
14 2
15 12
15 12
16 1
16 1
17 16
17 16
18 17
18 17
19 12
19 12
20 12
20 12
21 5
21 5
22 18
22 18
23 13
23 13
24 13
24 13
25 14
25 14
26 2
26 2
27 7
27 7
28 20
28 20
29 4
29 4
30 8
3...

output:

2044
3334
1350
4292
3110
3522
4360
4282
2098
3370
2698
4072
3604
2726
760
2266
1180
3936
2894
4378
2848
3274
1224
2020
1630
3866
1984
2706
2454
4448
610
4180
1716
4480
2580
2932
2634
3118
2268
2286
3758
768
4514
4024
4178
3394
2840
2318
4234
834
3838
2310
1006
1036
2926
2864
3434
2670
3790
2254
3998...

result:

ok 297818 lines

Test #55:

score: 0
Accepted
time: 137ms
memory: 19340kb

input:

2397 4792
2 1
2 1
3 2
3 2
4 3
4 3
5 4
5 4
6 5
6 5
7 6
7 6
8 7
8 7
9 8
9 8
10 9
10 9
11 10
11 10
12 11
12 11
13 12
13 12
14 13
14 13
15 14
15 14
16 15
16 15
17 16
17 16
18 17
18 17
19 18
19 18
20 19
20 19
21 20
21 20
22 21
22 21
23 22
23 22
24 23
24 23
25 24
25 24
26 25
26 25
27 26
27 26
28 27
28 27
...

output:

4574
4564
3910
3068
4556
3224
2484
4034
3914
3750
3524
3752
4152
3716
4344
558
3600
2274
1304
4110
4732
4456
886
3692
2360
3026
4190
2210
2386
3256
3872
1288
4002
3698
2304
1578
2448
2004
3666
3004
2672
3230
1892
3818
3430
1414
2866
3958
748
3520
1958
3732
4618
3768
4640
3184
3098
2040
4456
4438
406...

result:

ok 296623 lines

Subtask #4:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #56:

score: 40
Accepted
time: 5ms
memory: 18624kb

input:

2 0
1
1 2

output:

-1

result:

ok single line: '-1'

Test #57:

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

input:

2 1
1 2
1
1 2

output:

-1

result:

ok single line: '-1'

Test #58:

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

input:

2 2
1 2
1 2
1
1 2

output:

2

result:

ok single line: '2'

Test #59:

score: 0
Accepted
time: 85ms
memory: 46560kb

input:

286524 0
272121
202914 240681
83357 34766
146374 163132
255867 125237
256825 5373
35986 11643
59384 71031
14748 26807
126311 199096
8561 41655
130902 129853
186007 61772
79799 101409
193775 141161
169307 261699
6872 219441
160135 278991
74287 115293
118944 158392
81242 87785
198613 168091
126209 787...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 272121 lines

Test #60:

score: 0
Accepted
time: 164ms
memory: 33628kb

input:

700 244650
1 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 ...

output:

700
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
...

result:

ok 244650 lines

Test #61:

score: 0
Accepted
time: 784ms
memory: 56604kb

input:

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

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 283145 lines

Test #62:

score: -40
Wrong Answer
time: 297ms
memory: 73504kb

input:

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

output:

276660
276660
-1
276660
276660
276660
276660
-1
276660
276660
276660
276660
276660
276660
276660
276660
276660
276660
276660
276660
276660
276660
276660
276660
276660
-1
-1
-1
-1
276660
276660
276660
276660
276660
276660
276660
276660
276660
-1
276660
276660
276660
276660
276660
276660
-1
276660
276...

result:

wrong answer 3rd lines differ - expected: '276660', found: '-1'