QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109615#4915. 海胆slime65 6830ms205276kbC++149.2kb2023-05-29 21:36:212023-05-29 21:36:23

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 4ms
memory: 58748kb

input:

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

output:

4
0
3
3
1

result:

ok 5 number(s): "4 0 3 3 1"

Test #2:

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

input:

97
4 1
1 2
6 7
1 3
7 6
3 1
4 5
1 2
3 5
3 2
29 2
31 94
8 80
32 8
46 8
8 31
31 29
32 29
12 32
2 1
1 3
7 2
6 8
3 2
3 2
3 4
5 1
2 3
3 2
4 1
4 8
5 3
1 2
2 1
4 9
1 3
2 4
6 5
62 9
7 27
27 64
88 27
88 64
27 9
6 9
2 3
8 5
5 7
8 4
5 4
1 2
3 2
10 5
2 1
1 2
2 5
2 1
2 1
5 3
9 2
1 3
3 2
1 3
3 5
3 4
2 4
4 6
3 1
2 ...

output:

87
0
10
19
9
1
47
1
12
16
0
64
13
15
54
54
40
4
0
52
35
35
15
0
4
68
61
31
63
35
13
29
44
21
27
2
13
50
0
48
35
73
1
42
35
42
68
48
8
3
44
40
27
52
54
24
3
0
20
21
14
35
2
9
22
70
5
39
16
0
55
43
14
22
20
47
55
48
22
31
25
4
42
0
26
21
51
42
35
27
24
34
44
8
51
36

result:

ok 96 numbers

Test #3:

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

input:

99
4 3
8 9
1 2
28 21
21 28
72 40
85 80
99 75
73 47
42 47
42 73
47 27
3 5
3 2
65 22
2 3
75 35
76 55
85 81
95 63
75 35
30 58
61 69
68 87
56 21
23 97
53 47
40 47
54 91
39 32
32 54
47 91
96 61
15 60
96 43
60 96
96 60
99 60
34 87
68 56
29 16
37 77
83 2
71 70
96 89
37 30
26 8
45 88
68 27
46 57
51 57
8 27
...

output:

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

result:

ok 95 numbers

Test #4:

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

input:

99
4 7
4 5
5 3
1 2
1 2
4 3
4 2
1 2
10 5
4 7
5 2
8 7
38 62
52 8
80 98
21 19
94 7
80 49
21 79
94 49
21 7
80 79
3 1
4 7
6 3
35 95
41 94
95 41
94 35
98 35
3 1
2 5
2 1
2 1
3 2
1 2
10 9
3 7
1 3
4 3
9 7
4 7
1 2
3 4
3 1
2 7
1 4
10 8
2 1
3 8
5 1
4 2
4 3
3 2
7 9
5 7
3 1
4 5
2 3
6 5
1 2
1 7
4 3
3 6
2 3
3 1
8 4...

output:

73
21
65
22
21
2
54
8
4
47
30
39
4
0
18
14
1
40
0
27
4
2
0
15
0
60
40
0
0
4
8
11
49
46
1
12
32
5
1
33
24
0
6
16
7
3
5
0
0
13
49
34
8
12
32
55
0
22
39
59
0
31
60
21
25
2
9
59
23
9
31
17
16
0
17
52
59
42
23
45
0
62
63
3
5
0
38
19
40
32
10
53
8
1
8
0
8
13

result:

ok 98 numbers

Test #5:

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

input:

100
5 6
3 5
1 6
1 4
6 5
9 6
2 4
7 2
1 2
78 17
68 78
68 17
16 17
5 1
2 3
4 1
98 54
97 20
62 98
81 62
20 95
95 81
97 98
2 1
2 7
8 5
3 6
5 1
2 7
8 7
2 6
4 8
1 3
1 3
2 1
4 1
1 2
87 29
51 38
87 51
51 87
28 87
71 12
71 12
3 1
1 2
2 4
2 4
3 1
38 59
15 38
15 74
74 59
81 59
2 6
9 5
94 65
59 14
59 18
18 65
14...

output:

68
36
18
30
43
17
2
33
13
16
33
0
8
24
37
19
21
0
2
49
0
24
42
23
36
28
0
56
13
30
0
29
19
5
0
20
3
12
9
4
38
30
38
40
9
0
6
25
33
19
26
4
38
37
21
12
48
17
40
6
12
2
33
22
28
53
63
28
0
36
26
19
25
3
64
13
2
0
2
28
2
17
11
2
34
30
29
40
4
14
22
38
5
26
52
22
2
42
42
15

result:

ok 100 numbers

Test #6:

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

input:

100
6 3
2 1
2 8
1 10
1 3
2 1
1 3
1 2
4 2
3 5
5 1
8 18
18 29
18 29
6 5
3 6
4 2
2 1
4 3
10 2
3 1
3 2
2 3
31 91
1 4
42 31
91 67
42 67
21 67
67 73
2 1
7 8
3 1
1 5
2 1
3 2
4 3
3 5
9 3
65 44
87 44
2 8
1 6
33 44
2 4
3 9
1 3
6 7
5 8
16 44
16 65
44 86
16 44
73 5
18 73
18 44
5 16
16 30
57 16
64 73
18 59
2 1
8...

output:

60
4
21
49
0
14
16
0
0
17
38
51
0
38
2
1
5
32
27
5
33
2
21
8
34
19
0
60
3
1
37
28
6
54
1
0
24
9
0
45
22
18
36
56
30
16
1
4
2
4
12
19
27
0
31
53
0
10
14
0
2
26
0
0
2
29
26
41
5
2
19
20
14
4
20
10
30
58
18
1
11
32
0
26
2
0
0
23
0
0
0
28
37
9
0
20
18
6
45
41

result:

ok 100 numbers

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #7:

score: 15
Accepted
time: 8ms
memory: 58900kb

input:

498
1 2
185 374
112 96
1 5
1 2
32 63
151 32
436 196
242 2
269 186
288 277
109 165
360 493
394 414
29 435
21 436
310 98
29 317
397 32
400 485
394 248
471 288
438 40
109 394
284 268
112 75
493 437
176 493
432 185
259 286
391 485
242 155
227 256
1 397
423 155
149 310
471 308
331 358
269 436
242 149
244...

output:

308
49
120
148
8
171
2
142
45
118
127
123
0
176
49
49
50
59
75
44
1
20
146
132
308
176
176
0
43
294
176
109
127
235
59
13
20
127
114
176
39
19
156
0
45
0
42
176
256
71
20
159
0
186
105
50
120
128
99
171
33
133
36
177
154
136
142
192
178
3
287
181
49
137
0
13
90
0
165
239
0
22
0
86
159
215
1
0
68
132...

result:

ok 498 numbers

Test #8:

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

input:

500
3 6
2 3
2 1
1 8
5 7
7 8
3 9
1 2
2 1
1 3
1 2
3 1
3 1
2 1
1 4
9 7
7 8
5 1
1 2
2 6
6 3
1 2
2 1
1 3
6 2
3 4
7 5
5 3
1 2
8 5
5 10
1 2
1 8
5 6
7 4
3 1
1 3
1 2
1 3
1 2
2 3
1 2
4 10
5 4
2 1
2 1
333 94
57 487
28 57
161 20
259 244
31 397
124 435
358 111
401 191
70 161
499 70
499 373
308 400
172 17
400 358...

output:

480
102
134
203
45
8
167
134
84
104
196
85
94
94
94
249
179
181
65
40
219
40
10
0
465
0
105
29
151
190
435
30
29
334
0
377
0
105
0
29
195
224
2
167
224
0
84
218
65
16
224
105
17
65
195
105
137
36
174
176
181
68
196
0
81
95
14
65
134
55
190
19
13
0
367
134
55
45
0
40
10
16
30
0
94
66
29
331
20
65
65
...

result:

ok 500 numbers

Test #9:

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

input:

500
3 5
387 191
212 238
449 389
58 137
58 137
418 214
315 412
455 204
232 36
3 238
140 242
242 140
484 304
164 314
35 121
464 79
257 492
451 185
22 288
209 383
3 455
295 314
499 397
393 418
205 127
58 418
23 418
455 263
110 335
314 18
464 368
397 299
58 356
464 121
85 58
451 391
397 129
397 314
451 ...

output:

319
185
74
26
50
118
127
92
26
54
50
92
82
93
177
94
24
0
63
95
3
24
221
129
128
0
180
50
50
0
0
145
0
246
0
121
0
0
93
143
220
121
157
0
59
97
50
23
249
95
23
0
47
24
119
124
218
50
1
21
79
3
30
128
50
86
27
24
249
142
69
30
84
94
41
122
108
0
97
48
15
180
92
47
26
1
29
143
180
26
95
29
1
25
24
24
...

result:

ok 500 numbers

Test #10:

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

input:

500
7 3
2 6
3 1
1 2
1 2
10 3
2 3
3 1
4 3
9 1
1 4
8 3
3 1
1 5
6 8
2 1
2 3
3 2
3 2
4 6
3 7
2 1
4 6
1 2
1 7
3 4
4 2
2 1
120 79
3 2
5 4
374 449
22 193
354 234
1 2
2 1
363 449
193 308
193 418
271 453
193 20
54 256
467 245
43 256
54 43
120 272
421 216
193 336
193 251
296 193
301 453
427 421
120 377
449 48...

output:

594
4
0
20
52
592
64
61
413
0
127
5
13
51
69
477
48
59
61
9
130
9
54
73
48
68
141
13
60
0
141
147
21
52
57
0
13
0
65
133
109
0
64
71
20
7
440
425
61
86
9
562
0
89
40
57
474
1
64
3
61
64
60
10
13
0
455
487
13
54
66
477
40
412
9
413
65
478
13
23
8
74
0
84
65
413
123
57
321
72
72
23
0
64
23
9
3
453
155...

result:

ok 500 numbers

Test #11:

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

input:

500
1 2
5 3
1 2
2 1
1 3
5 7
6 7
1 4
8 3
2 4
5 6
1 2
6 3
1 9
2 4
2 4
1 2
2 1
4 1
2 3
1 6
2 1
9 7
1 2
6 3
4 1
1 2
1 3
4 3
2 1
1 6
2 1
5 2
4 1
3 4
4 3
7 8
10 3
3 4
2 1
6 1
4 2
7 8
2 1
2 5
6 5
3 4
1 2
7 4
1 2
9 4
1 4
3 1
1 3
1 3
8 3
1 3
2 1
1 2
3 2
2 3
1 3
1 2
2 1
111 159
111 159
3 2
3 2
2 6
4 3
1 6
10 ...

output:

768
505
108
8
643
107
60
34
320
46
718
664
97
2
105
0
3
24
165
483
572
26
726
517
57
531
565
49
25
627
34
29
548
208
629
511
486
4
530
665
24
33
10
79
25
706
654
644
146
4
127
72
524
21
90
538
647
621
51
5
20
203
54
522
602
15
51
683
622
650
113
186
651
550
103
11
50
547
190
43
93
72
510
85
77
13
71...

result:

ok 500 numbers

Subtask #3:

score: 15
Accepted

Dependency #2:

100%
Accepted

Test #12:

score: 15
Accepted
time: 18ms
memory: 61192kb

input:

4996
1 10
2 3
5 6
4 2
6 1
5 2
2 1
3 1
4 2
4 3
4 3
1 7
1 3
1 2
2 1
4 3
6 5
3 6
3 1
3 2
1 5
2 6
1 2
9 1
7 3
3 2
2 3
3 1
9 3
4 3
4 5
6 5
1 3
4 3
7 2
1 2
1 2
6 2
2 1
6 4
3 2
7 2
1 2
1 3
5 1
1 6
7 2
6 2
1 8
2 1
7 4
4 1
2 1
3 4
2 5
8 1
8 5
5 3
2 1
3 6
1 4
1 3
1 2
1 5
7 2
7 4
1 4
4 3
1 3
4 7
6 1
4 2
5 6
9 ...

output:

5990
188
3230
1916
0
189
3683
5361
5603
0
1915
930
188
5302
1916
1
2532
5475
1915
213
18
48
220
3481
1933
1891
0
1690
931
18
1934
170
1702
221
0
3682
214
5280
4
5412
1879
1916
5027
170
1933
1
4505
1003
1701
18
1
5545
2103
0
1916
1933
3326
188
2784
3485
0
2532
612
1698
1702
1934
18
0
1
1891
3522
0
21...

result:

ok 4996 numbers

Test #13:

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

input:

5000
6 7
4 10
2 3
3 2
2 1
1 3
4 5
1 2
4 2
1 2
1 2
2 3
2 9
4 1
1 2
2 1
5 1
3 6
1 3
1 3
2 3
3 2
5 4
1 5
2 1
2 3
1 8
1 2
2 4
1 2
6 9
1 3
3 2
2 3
8 2
5 2
2 3
2 1
4 1
146 4036
3203 2822
2892 694
1131 3233
3525 332
1221 756
1229 1536
2178 694
694 2350
2343 3589
1603 4810
2613 1336
4810 694
1336 964
2343 2...

output:

6803
177
2658
1812
557
5319
2745
795
4340
2516
5276
1780
126
1042
1123
1666
3697
1482
2625
4000
939
3205
5060
4398
1396
1229
2245
1381
3672
1806
2762
4291
491
1536
758
4
1297
1311
1238
3468
1703
672
2080
1229
2102
638
483
3257
3290
152
2435
4395
3604
1688
17
2035
529
2630
3070
2598
516
1138
3356
585...

result:

ok 5000 numbers

Test #14:

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

input:

5000
1 6
3 1
4 7
4 2
1 3
2 1
4 2
1 6
2 3
5 1
1 2
1 4
1 3
1 2
9 6
1 2
1 7
6 5
4 3
6 1
2 1
6 2
8 1
2 3
6 4
3 2
3 1
4 1
6 3
3 1
2 1
3 1
4 5
2 3
9 8
2 3
3 1
2 1
3 2
4 8
1 5
2 1
1 2
2 9
7 3
10 6
5 2
1 7
2 1
1 2
2 1
3 1
8 2
3 6
3 8
1 3
1 6
7 3
6 10
5 1
6 1
6 7
3 4
3 1
5 8
7 5
2 6
2 4
2 3
1 2
3 1
5 4
1 3
3...

output:

12605
9835
8732
5742
10572
31
914
879
1118
1092
11911
10888
7832
15
977
10837
9835
8735
11584
9473
0
561
6380
6864
1862
7986
9968
11168
6380
11230
9678
10691
413
992
9
1661
1136
2066
9835
1355
3775
10317
2010
10725
1299
1366
0
3833
3146
6879
11435
3
11617
10469
9832
11849
2041
11090
8732
4165
11259
...

result:

ok 5000 numbers

Test #15:

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

input:

5000
1 3
1 3
5 2
2 1
3 1
1 3
3 4
4 1
2 1
5 7
3 5
10 5
3 2
2 5
1 3
2 3
7 2
3 5
3 2
3 1
3 1
1 3
3 5
1 5
2 4
3 2
3 1
3 6
1 3
1 2
2 1
2 1
1 2
7 4
3 2
8 4
1 8
1 2
3 5
4 3
2 1
5 1
3 1
5 3
1 2
2 1
7 4
3 5
1 2
1 2
5 4
3 5
1 3
1 3
2 3
3 4
5 7
5 3
5 6
6 5
7 2
2 6
1 3
5 1
2169 2173
3017 3079
3431 2217
2029 221...

output:

9253
1207
5979
844
7864
1678
5183
5565
2115
5531
1124
4383
5771
5458
1661
1
1164
2056
1220
2544
565
7704
2256
5105
9075
3327
613
2380
3328
64
1807
1630
222
6579
4560
5391
848
3627
690
868
7425
512
0
2420
1
3083
2502
2368
4972
5699
4255
668
13
4360
811
7262
443
6919
6166
223
5508
4590
4867
1365
5582
...

result:

ok 5000 numbers

Test #16:

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

input:

5000
1 6
6 8
1 3
3 7
5 7
1 2
1 5
2 8
7 5
7 3
2 4
6 2
1 2
5 3
1 2
10 6
2 3
5 2
8 1
6 1
1 7
1 5
2 4
3 2
6 1
2 4
2 7
1 2
2 1
2 5
1 2
1 6
2 1
2 3
5 1
3 7
5 2
9 4
4 5
1698 2236
2166 3865
2236 2166
1526 1530
2166 1439
10 6
5 6
2 1
8 6
1530 1439
1439 4499
1439 2166
2 6
4 1
2 1
4 2
1 5
2 7
4 8
3 7
2 1
6 2
1...

output:

31787
14922
0
15031
28287
28459
27154
27082
362
275
8292
224
673
206
27679
27755
31139
15862
27358
0
27082
4507
27637
0
3301
388
31102
28115
27358
30
27082
3073
27637
12899
27366
27999
118
27639
137
601
30632
276
14250
29067
0
27639
673
16535
7458
179
31245
27785
26
31314
7
27358
0
23002
477
616
276...

result:

ok 5000 numbers

Subtask #4:

score: 15
Accepted

Dependency #3:

100%
Accepted

Test #17:

score: 15
Accepted
time: 122ms
memory: 69028kb

input:

50000
4 1
6 7
2 1
2 3
6 3
4 5
6 1
3 7
3 2
1 2
2 3
1 2
2 1
2 4
7 6
1 3
1 3
1 4
4 7
5 1
2 1
2 1
3 1
2 3
4 5
1 4
5 8
4 2
4 3
4 6
5 1
4 5
8 6
4 7
5 4
1 6
4 8
8 3
4 6
2 4
2 4
6 1
8 6
2 1
2 1
6 3
4 1
1 2
1 6
3 4
4 5
9 2
8 2
8 7
4 5
5 4
9 7
5 1
1 4
1 5
9 3
4 1
2 4
1 2
1 5
9 3
2 1
3 2
2 1
1 3
3 5
3 1
4 2
7 ...

output:

60000
26923
28354
17155
40133
31923
43127
7928
47066
3635
463
7456
5576
3632
2450
42642
301
23261
14424
12169
19848
1754
10509
27037
16843
9877
12621
8980
14833
186
2922
8726
7078
33377
20304
30278
16385
36956
30881
8472
27786
18608
16056
16701
5444
35616
26112
18246
41122
25299
23090
29792
28830
31...

result:

ok 50000 numbers

Test #18:

score: 0
Accepted
time: 131ms
memory: 71204kb

input:

49999
1 2
1 2
2 1
3 1
5 6
1 3
8 4
3 1
1 6
2 1
2 1
10 2
2 3
2 1
3 5
1 2
5 6
3 4
7 6
4 3
6 7
4 1
2 3
7 2
5 2
8 7
2 3
1 2
4 3
5 1
7 2
1 2
6 4
3 2
6 1
3 1
3 4
6 3
6 1
3 6
1 3
6 3
1 2
5 3
3 1
1 2
1 3
2 1
4 2
1 2
5 7
1 3
1 3
2 1
1 8
2 3
1 3
1 7
1 5
5 2
1 3
4 2
9 8
3 1
6 5
5 6
2 3
1 3
3 1
4 3
1 2
2 1
7 1
2...

output:

275937
237662
6643
82
266693
250205
221014
6144
22015
29245
2463
241142
262488
699
253306
20482
1463
21146
21347
266789
2933
14665
14157
226993
245656
12959
260207
243637
9643
230967
247631
1535
265005
2957
2385
246162
238096
247074
192442
4176
268404
231484
25479
32421
244399
259415
124552
251385
2...

result:

ok 49995 numbers

Test #19:

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

input:

50000
5 4
2 3
10 2
8 6
2 5
2 1
7 6
6 2
5 2
6 4
4 1
4 8
2 1
2 4
8 1
3 4
3 1
5 4
7 2
1 2
4 5
8 9
6 2
3 1
1 2
2 1
1 2
2 1
5 1
1 3
5 3
6 7
1 7
2 1
1 3
4 3
2 8
1 2
4 7
1 2
1 3
2 1
4 7
2 5
7 3
10 4
3 6
2 4
2 6
4 1
4 2
4 6
2 5
2 1
2 5
5 3
5 4
6 7
2 1
3 2
2 1
10 7
2 1
6 4
3 2
1 2
1 2
1 3
2 3
3 1
6 5
2 1
3 6...

output:

169213
120366
76907
32378
7198
86993
61596
80803
38569
75542
36937
14528
115397
77020
37755
79637
145452
3613
82267
96362
64481
47922
54959
52825
12360
72937
93542
26569
102097
96296
79162
855
78073
10019
15141
2770
59873
114110
86624
37344
42028
16224
140031
37635
39580
10943
110851
146778
128030
1...

result:

ok 50000 numbers

Test #20:

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

input:

49997
2 10
1 3
4 1
5 2
8 5
7 2
3 1
2 5
1 4
3 1
48597 7937
14962 3483
48818 47114
34306 1793
1 6
8 2
6 3
8 2
8 2
7 6
1 6
3 1
9331 47946
48818 36815
7937 40900
40138 23406
16468 9709
9400 30978
11754 48597
48818 21416
47946 38519
47946 21416
9400 1812
1793 9400
40138 30663
11643 16468
11754 23513
2234...

output:

157269
33653
23819
76455
118476
44543
59046
49422
28610
17548
65694
39585
16855
16067
28735
49686
149418
83164
58263
29198
109035
5047
48160
38826
127708
34779
20530
68913
76799
31109
114263
85023
86767
44417
66800
15486
102030
88200
21214
22070
40559
59311
17401
3957
78119
97658
72965
20499
16132
5...

result:

ok 49998 numbers

Test #21:

score: 0
Accepted
time: 138ms
memory: 69240kb

input:

50000
3 6
6 1
5 2
1 2
2 4
6 1
5 4
2 6
4 5
5 1
5 4
4 7
3 5
2 1
5 1
8 3
1 10
3 2
6 4
3 1
3 5
3 2
1 2
1 6
2 3
8 4
2 3
2 1
2 3
6 2
6 5
2 1
1 2
2 5
3 2
7 2
5 2
8 9
4 2
5 3
3 1
1 3
6 2
7 4
3 2
6 3
2 1
7 3
2 1
5 6
2 3
5 4
1 3
1 2
6 7
2 3
2 1
8 4
1 2
1 6
1 7
3 1
3 1
5 6
1 3
8 3
7 3
2 3
7 6
5 6
2 1
3 1
1 2
3...

output:

162140
42246
96814
25397
33104
47007
29382
77557
3269
53838
10943
5831
101194
131296
34710
45033
61613
68985
69533
79053
28544
35179
121526
15199
6224
73763
28819
48551
58273
48436
21773
96820
12508
28490
25110
3535
126369
113968
28886
36446
84547
95587
14431
7643
71545
13732
44292
28572
42936
20078...

result:

ok 50000 numbers

Subtask #5:

score: 15
Accepted

Test #22:

score: 15
Accepted
time: 2800ms
memory: 154392kb

input:

1000000
1 2
1 4
2 1
3 6
6 5
1 3
10 5
2 4
9 6
3 2
1 2
5 1
4 3
1 3
1 4
2 9
6 4
1 2
1 2
1 2
3 4
3 4
7 5
1 2
1 2
2 1
7 8
1 2
5 4
1 3
2 1
4 2
1 4
1 4
4 2
1 3
1 3
7 4
3 4
3 2
2 1
1 2
1 2
2 5
10 6
2 3
2 5
7 2
5 4
4 5
5 7
2 1
8 5
2 1
2 1
1 3
4 6
3 1
2 5
4 8
6 3
1 4
1 2
1 3
9 8
6 5
3 4
3 2
1 3
4 2
1 6
2 1
1 ...

output:

11235160

result:

ok 1 number(s): "11235160"

Test #23:

score: 0
Accepted
time: 4604ms
memory: 164608kb

input:

1000000
1 2
8 2
8 6
4 8
6 10
2 7
2 1
3 1
2 3
9 1
6 4
2 1
5 3
1 2
3 5
2 4
3 2
3 1
4 2
7 4
3 9
3 2
2 1
1 6
5 1
3 2
1 2
8 3
4 2
2 1
5 6
1 2
2 1
3 1
7 1
2 3
4 5
1 4
5 6
4 1
9 7
3 2
1 5
2 5
2 1
1 2
5 7
5 3
5 4
4 3
1 2
4 1
1 4
9 8
6 4
1 5
10 3
7 6
6 1
3 2
2 1
3 2
5 3
2 5
2 3
4 3
1 7
5 2
3 4
2 4
3 2
6 2
4 ...

output:

1273941717

result:

ok 1 number(s): "1273941717"

Test #24:

score: 0
Accepted
time: 4229ms
memory: 166432kb

input:

1000000
2 7
5 4
1 2
3 4
4 6
1 3
2 5
4 5
8 2
5 2
4 1
8 7
5 6
5 4
3 4
2 4
1 2
1 2
2 3
5 3
3 4
3 1
1 9
2 1
2 1
2 1
1 2
8 4
8 6
7 8
4 2
6 5
3 1
8 3
1 2
5 3
5 1
4 2
4 2
2 1
2 4
2 4
3 2
2 1
3 4
4 5
9 4
2 9
2 5
7 3
5 7
4 1
4 3
8 7
3 5
5 1
1 2
6 5
2 4
2 3
5 6
7 1
2 4
8 9
5 2
1 2
1 4
3 8
2 6
1 5
6 4
4 2
10 2...

output:

293147241

result:

ok 1 number(s): "293147241"

Test #25:

score: 0
Accepted
time: 3734ms
memory: 161296kb

input:

1000000
3 5
3 4
3 4
7 2
5 6
1 8
3 4
8 9
8 3
2 4
4 6
1 2
6 3
3 6
1 3
2 8
3 4
3 2
3 1
4 2
6 8
5 2
2 4
7 6
1 2
5 1
3 1
2 3
8 7
2 5
5 7
1 4
6 4
2 1
1 4
2 10
4 1
6 3
10 1
1 6
1 2
6 2
1 2
2 1
4 3
2 1
6 5
7 4
3 2
3 4
4 2
1 3
1 4
6 5
2 1
3 5
1 3
3 2
4 3
8 10
5 4
2 4
7 1
9 7
1 3
6 3
3 1
2 6
3 1
5 6
8 10
1 3
...

output:

6429173

result:

ok 1 number(s): "6429173"

Test #26:

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

input:

1000000
1 2
5 6
4 5
1 2
4 2
6 5
1 2
4 1
1 2
3 7
1 4
4 2
8 6
8 7
5 1
2 1
6 8
5 8
3 1
7 2
5 4
3 2
3 7
3 5
5 1
6 3
3 2
4 3
2 5
5 8
1 2
8 5
4 6
2 7
2 1
2 5
1 2
2 8
1 10
3 2
2 1
1 4
3 10
5 1
2 6
2 1
5 1
1 4
10 6
2 5
2 1
3 1
5 6
3 2
3 4
3 5
2 5
10 7
4 2
1 2
1 2
4 2
6 4
3 2
1 6
2 1
7 2
6 1
3 5
3 2
5 8
5 3
...

output:

11021330

result:

ok 1 number(s): "11021330"

Subtask #6:

score: 0
Wrong Answer

Test #27:

score: 0
Wrong Answer
time: 6830ms
memory: 205276kb

input:

1000000
194603 719066
675018 226509
79442 45350
917512 353429
61308 216895
411878 891116
152492 299355
285259 500703
362450 305858
809620 298590
353068 307896
594296 243696
962716 546635
865529 461074
454115 255260
569303 319052
266164 139614
575510 107514
840723 802795
583117 41941
891173 661899
94...

output:

9091998699
0
0
0
0
0
346906248
0
0
1143585630
0
0
0
0
0
0
-1161541964
0
0
382788441
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1968813432
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
815116...

result:

wrong answer 17th numbers differ - expected: '7428392628', found: '-1161541964'

Subtask #7:

score: 0
Skipped

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

0%