QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#234192#44. PathsGMBox100 ✓148ms77068kbC++17891b2023-11-01 14:45:532023-11-01 14:46:09

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 23
Accepted

Test #1:

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

input:

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

output:

1316

result:

ok single line: '1316'

Test #2:

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

input:

100 100 4
1 2 1 2 2 3 2 4 1 2 3 2 2 3 1 4 1 3 2 3 4 4 2 3 1 4 3 4 1 4 2 4 1 3 4 2 2 1 1 2 3 2 2 3 4 2 4 1 4 2 1 1 2 2 3 1 2 4 1 4 2 2 4 3 3 2 4 1 3 1 2 3 3 4 1 2 4 3 4 2 1 1 4 4 4 3 1 1 4 2 3 3 2 4 4 2 2 2 1 1
57 14
39 28
36 49
9 35
17 12
74 16
65 34
69 29
95 16
72 85
27 85
68 45
85 76
49 99
46 31
7...

output:

404

result:

ok single line: '404'

Test #3:

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

input:

50 100 3
2 1 1 1 1 1 1 1 2 3 2 1 2 3 2 3 2 2 2 2 3 2 3 3 1 1 1 2 3 1 3 1 2 1 3 3 1 2 1 3 3 1 2 1 2 3 2 2 2 2
25 13
16 25
35 25
33 8
48 42
15 16
36 33
5 4
16 32
31 34
19 28
6 30
39 43
50 19
10 50
13 15
13 29
30 18
46 21
39 35
45 8
43 14
23 48
26 23
1 35
47 32
13 22
29 24
40 32
21 38
30 44
44 46
33 6
...

output:

348

result:

ok single line: '348'

Test #4:

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

input:

50 100 2
2 1 2 1 2 2 1 1 1 2 1 1 1 2 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 2 2 2 1 2
37 11
3 45
26 21
26 33
16 49
25 7
21 14
43 48
21 40
4 11
30 34
40 43
5 21
12 32
34 42
38 4
2 15
4 1
41 45
49 48
30 8
42 20
34 44
50 5
5 49
34 16
50 33
41 15
18 47
23 8
37 19
48 26
19 33
11 36...

output:

94

result:

ok single line: '94'

Test #5:

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

input:

50 100 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41 25
26 50
33 20
38 35
22 25
14 50
12 15
20 19
23 8
44 50
22 42
9 50
39 21
26 20
44 23
24 31
12 28
23 49
25 14
43 37
2 24
8 19
26 11
43 5
9 18
47 22
9 28
50 27
30 5
22 28
7 6
48 18
37 47
15 ...

output:

0

result:

ok single line: '0'

Test #6:

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

input:

100 100 4
4 1 3 3 4 3 4 2 4 3 2 1 2 2 3 2 4 2 2 3 4 1 4 3 4 3 2 3 2 3 1 4 1 4 1 1 1 1 1 1 1 3 4 4 3 1 1 2 1 1 4 2 4 4 3 3 2 1 4 2 2 3 2 3 2 1 2 3 2 4 1 1 4 3 1 1 1 4 2 3 1 3 2 3 4 3 3 4 2 2 1 1 1 2 4 2 4 4 2 1
91 30
94 91
38 91
72 91
23 91
91 4
91 33
91 18
91 41
91 14
91 5
39 91
100 91
50 91
91 6
43...

output:

3598

result:

ok single line: '3598'

Test #7:

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

input:

60 99 4
3 2 1 2 3 1 2 3 3 1 3 1 1 1 2 1 3 1 2 2 1 2 1 3 1 1 3 2 3 3 3 3 3 2 1 2 1 2 3 2 2 3 2 2 3 1 1 2 1 1 2 2 2 1 3 1 3 3 4 3
59 27
21 57
4 59
28 40
47 18
45 59
40 59
17 59
59 32
32 7
12 17
44 59
41 59
59 51
57 35
54 43
50 60
37 8
53 17
25 55
28 51
59 28
35 27
38 59
9 59
28 60
6 42
36 59
11 51
26 ...

output:

2406

result:

ok single line: '2406'

Test #8:

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

input:

100 100 4
4 2 3 1 2 4 4 1 4 4 4 4 4 3 1 1 2 1 1 4 4 3 3 3 2 1 3 3 3 1 1 2 1 4 2 3 4 3 2 2 3 2 3 1 3 4 2 1 2 2 4 2 3 2 3 3 1 2 2 2 4 1 4 3 2 1 3 1 4 4 2 2 2 2 4 3 2 4 2 1 1 3 1 3 4 4 2 1 2 4 3 4 3 2 1 2 1 4 4 4
45 72
77 72
25 27
13 14
92 25
33 70
94 71
82 24
100 66
72 64
88 11
73 16
16 40
19 10
31 26...

output:

316

result:

ok single line: '316'

Test #9:

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

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #10:

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

input:

3 3 3
1 3 2
3 1
1 2
2 3

output:

12

result:

ok single line: '12'

Subtask #2:

score: 20
Accepted

Test #11:

score: 20
Accepted
time: 43ms
memory: 22160kb

input:

5000 300000 3
3 1 3 3 3 1 3 2 2 1 3 3 1 2 3 3 3 1 2 3 2 3 2 3 3 1 3 3 2 2 1 2 1 2 1 1 1 3 3 3 1 2 3 3 1 3 2 2 2 1 1 3 1 3 3 1 2 3 3 2 1 2 1 2 1 3 3 3 3 3 1 3 1 2 3 2 2 3 2 1 2 2 2 2 1 3 2 2 3 3 3 1 1 2 3 2 1 1 2 2 1 1 2 2 1 3 3 1 1 2 3 1 2 3 3 3 2 2 2 3 1 3 2 3 1 3 2 3 3 3 1 2 3 3 3 2 2 2 3 3 3 1 3 ...

output:

16436298

result:

ok single line: '16436298'

Test #12:

score: 0
Accepted
time: 32ms
memory: 20428kb

input:

800 300000 3
2 3 1 2 3 1 1 1 1 3 2 1 2 3 2 2 3 3 3 3 2 2 3 3 2 2 1 2 3 2 3 1 2 1 3 3 3 1 2 2 1 1 1 2 3 3 3 2 2 1 1 3 3 3 1 2 2 3 1 3 1 1 1 3 3 1 2 1 1 3 3 2 2 2 2 3 2 2 3 2 1 1 2 3 1 3 2 2 3 3 2 2 2 3 2 1 1 3 3 3 1 1 3 2 2 1 3 1 2 3 1 3 1 1 1 1 1 2 3 3 2 2 3 3 2 1 3 3 3 1 1 1 3 3 1 1 2 2 3 2 1 2 3 3...

output:

100589586

result:

ok single line: '100589586'

Test #13:

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

input:

300000 300000 3
2 3 3 2 3 3 2 2 2 2 3 1 3 1 1 1 1 1 1 1 1 1 1 3 2 2 1 1 3 3 2 1 1 2 3 1 2 3 2 2 3 1 1 3 1 2 2 2 2 1 2 2 1 1 2 2 2 3 2 2 1 1 3 3 2 1 1 1 3 1 1 3 3 2 2 3 3 1 2 2 2 1 2 1 2 2 3 1 2 3 1 2 2 2 3 2 1 3 1 1 1 3 3 2 3 2 3 3 3 3 1 1 2 2 3 1 1 1 3 2 1 1 2 1 2 1 3 3 2 1 1 1 2 2 2 2 1 1 1 1 2 2 ...

output:

665606

result:

ok single line: '665606'

Test #14:

score: 0
Accepted
time: 46ms
memory: 15556kb

input:

30000 300000 2
2 2 1 2 1 2 2 1 2 1 1 2 2 1 2 2 2 2 2 2 1 2 2 1 1 2 1 1 1 2 2 1 2 1 2 1 2 2 1 2 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 2 2 2 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 1 1 2 1 1 2 2 2 1 2 2 2 1 1 2 2 2 2 1 1 2 1 2 2 2 1 1 1 2 1 2 1 2...

output:

299694

result:

ok single line: '299694'

Test #15:

score: 0
Accepted
time: 34ms
memory: 10668kb

input:

30000 300000 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 89ms
memory: 28920kb

input:

200000 299999 3
3 3 1 1 2 1 1 2 2 2 2 3 1 3 1 2 2 3 3 2 2 3 2 1 1 1 3 3 2 1 1 2 2 1 2 3 2 3 1 3 3 3 1 2 1 1 3 3 1 1 2 2 1 2 2 3 1 3 2 3 1 2 3 3 3 1 2 2 1 1 1 2 1 3 1 1 3 1 3 3 3 2 1 2 2 3 3 3 1 1 2 2 2 2 2 1 2 2 2 1 3 1 3 1 3 1 2 1 2 3 1 1 2 1 1 1 3 1 3 1 3 3 1 3 1 1 1 2 1 2 2 1 3 3 3 3 3 2 2 1 3 3 ...

output:

8922060294

result:

ok single line: '8922060294'

Test #17:

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

input:

300000 300000 3
3 2 2 1 1 2 3 1 3 2 2 3 3 2 3 2 2 2 2 3 3 1 1 1 1 1 2 3 1 1 3 2 1 3 1 2 1 3 1 1 2 3 2 2 2 3 1 2 1 3 1 3 3 3 2 2 2 1 1 2 2 3 3 3 3 2 1 1 2 1 1 1 1 2 3 2 2 1 2 2 3 1 3 2 2 3 3 2 3 2 2 1 2 2 2 1 1 1 3 3 3 2 1 3 1 1 2 3 3 1 2 1 2 3 3 3 2 2 1 3 1 3 1 1 2 1 2 1 1 1 3 1 1 3 1 2 1 1 2 1 1 3 ...

output:

666528

result:

ok single line: '666528'

Test #18:

score: 0
Accepted
time: 103ms
memory: 31828kb

input:

300000 300000 3
1 3 1 1 2 1 1 1 3 1 2 3 1 3 1 2 2 3 1 3 1 2 2 2 1 3 3 3 2 1 3 3 2 1 2 2 3 1 2 3 1 3 1 3 1 1 1 3 3 2 3 3 2 1 2 1 3 2 2 1 2 2 2 1 2 2 2 2 1 1 2 1 1 3 2 1 1 1 3 1 3 3 2 1 3 3 3 1 3 3 1 2 1 2 3 1 1 2 1 2 3 2 3 1 1 1 1 3 2 1 2 3 2 3 2 2 3 3 3 3 1 3 2 3 3 1 3 1 2 3 2 2 2 1 1 2 3 3 2 3 3 2 ...

output:

577020

result:

ok single line: '577020'

Subtask #3:

score: 27
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #19:

score: 27
Accepted
time: 41ms
memory: 22072kb

input:

5000 300000 3
3 1 3 3 3 1 3 2 2 1 3 3 1 2 3 3 3 1 2 3 2 3 2 3 3 1 3 3 2 2 1 2 1 2 1 1 1 3 3 3 1 2 3 3 1 3 2 2 2 1 1 3 1 3 3 1 2 3 3 2 1 2 1 2 1 3 3 3 3 3 1 3 1 2 3 2 2 3 2 1 2 2 2 2 1 3 2 2 3 3 3 1 1 2 3 2 1 1 2 2 1 1 2 2 1 3 3 1 1 2 3 1 2 3 3 3 2 2 2 3 1 3 2 3 1 3 2 3 3 3 1 2 3 3 3 2 2 2 3 3 3 1 3 ...

output:

16436298

result:

ok single line: '16436298'

Test #20:

score: 0
Accepted
time: 27ms
memory: 20468kb

input:

800 300000 3
2 3 1 2 3 1 1 1 1 3 2 1 2 3 2 2 3 3 3 3 2 2 3 3 2 2 1 2 3 2 3 1 2 1 3 3 3 1 2 2 1 1 1 2 3 3 3 2 2 1 1 3 3 3 1 2 2 3 1 3 1 1 1 3 3 1 2 1 1 3 3 2 2 2 2 3 2 2 3 2 1 1 2 3 1 3 2 2 3 3 2 2 2 3 2 1 1 3 3 3 1 1 3 2 2 1 3 1 2 3 1 3 1 1 1 1 1 2 3 3 2 2 3 3 2 1 3 3 3 1 1 1 3 3 1 1 2 2 3 2 1 2 3 3...

output:

100589586

result:

ok single line: '100589586'

Test #21:

score: 0
Accepted
time: 129ms
memory: 32864kb

input:

300000 300000 3
2 3 3 2 3 3 2 2 2 2 3 1 3 1 1 1 1 1 1 1 1 1 1 3 2 2 1 1 3 3 2 1 1 2 3 1 2 3 2 2 3 1 1 3 1 2 2 2 2 1 2 2 1 1 2 2 2 3 2 2 1 1 3 3 2 1 1 1 3 1 1 3 3 2 2 3 3 1 2 2 2 1 2 1 2 2 3 1 2 3 1 2 2 2 3 2 1 3 1 1 1 3 3 2 3 2 3 3 3 3 1 1 2 2 3 1 1 1 3 2 1 1 2 1 2 1 3 3 2 1 1 1 2 2 2 2 1 1 1 1 2 2 ...

output:

665606

result:

ok single line: '665606'

Test #22:

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

input:

30000 300000 2
2 2 1 2 1 2 2 1 2 1 1 2 2 1 2 2 2 2 2 2 1 2 2 1 1 2 1 1 1 2 2 1 2 1 2 1 2 2 1 2 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 2 2 2 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 1 1 2 1 1 2 2 2 1 2 2 2 1 1 2 2 2 2 1 1 2 1 2 2 2 1 1 1 2 1 2 1 2...

output:

299694

result:

ok single line: '299694'

Test #23:

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

input:

30000 300000 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0

result:

ok single line: '0'

Test #24:

score: 0
Accepted
time: 91ms
memory: 29068kb

input:

200000 299999 3
3 3 1 1 2 1 1 2 2 2 2 3 1 3 1 2 2 3 3 2 2 3 2 1 1 1 3 3 2 1 1 2 2 1 2 3 2 3 1 3 3 3 1 2 1 1 3 3 1 1 2 2 1 2 2 3 1 3 2 3 1 2 3 3 3 1 2 2 1 1 1 2 1 3 1 1 3 1 3 3 3 2 1 2 2 3 3 3 1 1 2 2 2 2 2 1 2 2 2 1 3 1 3 1 3 1 2 1 2 3 1 1 2 1 1 1 3 1 3 1 3 3 1 3 1 1 1 2 1 2 2 1 3 3 3 3 3 2 2 1 3 3 ...

output:

8922060294

result:

ok single line: '8922060294'

Test #25:

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

input:

300000 300000 3
3 2 2 1 1 2 3 1 3 2 2 3 3 2 3 2 2 2 2 3 3 1 1 1 1 1 2 3 1 1 3 2 1 3 1 2 1 3 1 1 2 3 2 2 2 3 1 2 1 3 1 3 3 3 2 2 2 1 1 2 2 3 3 3 3 2 1 1 2 1 1 1 1 2 3 2 2 1 2 2 3 1 3 2 2 3 3 2 3 2 2 1 2 2 2 1 1 1 3 3 3 2 1 3 1 1 2 3 3 1 2 1 2 3 3 3 2 2 1 3 1 3 1 1 2 1 2 1 1 1 3 1 1 3 1 2 1 1 2 1 1 3 ...

output:

666528

result:

ok single line: '666528'

Test #26:

score: 0
Accepted
time: 117ms
memory: 31832kb

input:

300000 300000 3
1 3 1 1 2 1 1 1 3 1 2 3 1 3 1 2 2 3 1 3 1 2 2 2 1 3 3 3 2 1 3 3 2 1 2 2 3 1 2 3 1 3 1 3 1 1 1 3 3 2 3 3 2 1 2 1 3 2 2 1 2 2 2 1 2 2 2 2 1 1 2 1 1 3 2 1 1 1 3 1 3 3 2 1 3 3 3 1 3 3 1 2 1 2 3 1 1 2 1 2 3 2 3 1 1 1 1 3 2 1 2 3 2 3 2 2 3 3 3 3 1 3 2 3 3 1 3 1 2 3 2 2 2 1 1 2 3 3 2 3 3 2 ...

output:

577020

result:

ok single line: '577020'

Test #27:

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

input:

800 300000 4
3 2 4 4 1 4 1 3 2 4 3 2 3 1 2 3 2 2 2 2 4 1 4 3 4 2 2 4 1 2 1 3 2 2 2 1 4 3 4 2 1 1 1 2 3 1 2 4 3 1 4 3 2 1 1 4 1 4 1 1 3 3 2 2 1 2 3 2 4 4 4 4 1 3 2 3 3 3 4 3 4 2 2 3 4 4 1 3 1 4 2 2 4 4 1 3 3 2 4 1 1 1 1 3 4 2 3 1 2 3 2 3 4 2 4 2 1 4 2 4 3 1 4 4 4 4 2 1 2 2 2 4 3 2 3 3 2 1 3 1 4 1 4 4...

output:

31899888672

result:

ok single line: '31899888672'

Test #28:

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

input:

8000 300000 4
1 4 1 4 2 2 4 2 1 1 1 4 3 4 2 3 1 3 4 3 2 1 4 3 3 4 4 2 2 3 2 1 4 4 4 1 3 4 1 4 3 1 3 1 1 3 3 1 3 3 2 3 4 1 2 1 1 4 4 4 4 2 3 4 3 2 1 4 3 2 2 4 4 3 2 2 4 3 1 3 2 3 4 3 2 3 4 3 1 2 4 1 1 2 1 1 3 2 3 2 4 3 3 3 2 2 2 1 4 2 2 2 3 4 4 3 2 1 1 4 2 3 1 1 4 3 4 2 1 2 2 1 2 3 3 2 4 2 3 3 4 2 4 ...

output:

334222370

result:

ok single line: '334222370'

Test #29:

score: 0
Accepted
time: 144ms
memory: 49660kb

input:

300000 300000 4
1 3 3 3 4 4 3 3 3 2 1 2 2 1 4 3 3 1 3 2 4 2 1 2 4 3 2 2 4 3 3 4 1 3 2 4 3 3 4 2 2 2 4 2 4 1 4 3 1 1 2 4 2 2 2 3 2 2 2 2 1 3 2 4 4 1 2 2 2 4 3 2 4 1 3 3 4 1 3 4 1 4 2 2 4 2 2 2 1 3 3 3 1 3 4 1 1 1 3 3 3 4 2 3 1 3 2 3 3 2 4 2 1 4 2 2 3 2 2 3 4 3 4 2 2 4 3 4 4 1 3 4 2 4 1 1 2 3 2 1 3 3 ...

output:

1121790

result:

ok single line: '1121790'

Test #30:

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

input:

150000 299999 4
3 4 2 3 4 3 3 3 1 4 4 1 4 2 1 3 4 2 3 4 3 2 3 3 2 3 3 2 3 2 3 1 2 1 4 2 2 2 3 4 1 3 1 3 2 4 4 1 4 1 2 1 1 4 4 3 1 4 4 1 4 3 3 4 1 4 3 3 1 2 1 4 1 4 1 2 1 4 4 3 3 3 4 1 1 1 3 4 1 4 2 4 4 1 3 2 1 3 3 1 3 4 2 3 4 4 3 2 3 3 3 1 3 4 1 3 4 3 4 2 4 4 3 3 1 3 1 3 2 2 3 3 3 4 4 2 4 1 4 3 3 1 ...

output:

16831953826

result:

ok single line: '16831953826'

Test #31:

score: 0
Accepted
time: 106ms
memory: 42868kb

input:

150000 299999 4
3 4 4 3 4 3 4 2 2 2 4 4 3 3 3 2 3 4 2 3 3 3 3 2 4 2 3 3 2 2 4 3 3 2 3 4 4 4 4 4 4 2 2 2 4 3 2 4 4 2 3 4 3 3 4 2 3 3 4 4 2 3 2 4 2 3 2 4 4 4 3 3 2 4 3 3 2 4 4 2 4 3 4 2 3 4 2 4 4 3 3 2 4 3 4 4 4 4 4 2 3 3 4 3 3 3 3 2 4 4 3 2 4 3 4 2 2 4 3 3 2 3 3 3 4 2 2 3 3 4 3 4 3 4 2 2 3 3 2 4 2 3 ...

output:

16660046632

result:

ok single line: '16660046632'

Test #32:

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

input:

300000 300000 4
4 2 3 2 4 4 2 3 3 4 4 4 2 3 2 4 4 4 2 1 3 2 1 2 4 4 2 3 3 2 4 3 3 2 1 2 1 3 2 2 4 4 1 1 1 1 4 2 4 3 3 4 1 2 4 4 4 4 1 1 1 3 4 4 2 1 2 4 4 4 4 3 4 4 2 4 4 1 1 1 3 3 3 2 2 4 4 2 1 3 2 2 1 3 3 2 4 1 1 3 2 2 4 1 4 4 4 2 2 3 1 2 1 3 3 4 3 4 4 3 3 2 1 3 2 4 3 1 4 2 1 4 4 2 3 4 4 4 1 3 1 2 ...

output:

1126130

result:

ok single line: '1126130'

Test #33:

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

input:

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

output:

1316

result:

ok single line: '1316'

Test #34:

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

input:

100 100 4
1 2 1 2 2 3 2 4 1 2 3 2 2 3 1 4 1 3 2 3 4 4 2 3 1 4 3 4 1 4 2 4 1 3 4 2 2 1 1 2 3 2 2 3 4 2 4 1 4 2 1 1 2 2 3 1 2 4 1 4 2 2 4 3 3 2 4 1 3 1 2 3 3 4 1 2 4 3 4 2 1 1 4 4 4 3 1 1 4 2 3 3 2 4 4 2 2 2 1 1
57 14
39 28
36 49
9 35
17 12
74 16
65 34
69 29
95 16
72 85
27 85
68 45
85 76
49 99
46 31
7...

output:

404

result:

ok single line: '404'

Test #35:

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

input:

50 100 3
2 1 1 1 1 1 1 1 2 3 2 1 2 3 2 3 2 2 2 2 3 2 3 3 1 1 1 2 3 1 3 1 2 1 3 3 1 2 1 3 3 1 2 1 2 3 2 2 2 2
25 13
16 25
35 25
33 8
48 42
15 16
36 33
5 4
16 32
31 34
19 28
6 30
39 43
50 19
10 50
13 15
13 29
30 18
46 21
39 35
45 8
43 14
23 48
26 23
1 35
47 32
13 22
29 24
40 32
21 38
30 44
44 46
33 6
...

output:

348

result:

ok single line: '348'

Test #36:

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

input:

50 100 2
2 1 2 1 2 2 1 1 1 2 1 1 1 2 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 2 2 2 1 2
37 11
3 45
26 21
26 33
16 49
25 7
21 14
43 48
21 40
4 11
30 34
40 43
5 21
12 32
34 42
38 4
2 15
4 1
41 45
49 48
30 8
42 20
34 44
50 5
5 49
34 16
50 33
41 15
18 47
23 8
37 19
48 26
19 33
11 36...

output:

94

result:

ok single line: '94'

Test #37:

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

input:

50 100 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41 25
26 50
33 20
38 35
22 25
14 50
12 15
20 19
23 8
44 50
22 42
9 50
39 21
26 20
44 23
24 31
12 28
23 49
25 14
43 37
2 24
8 19
26 11
43 5
9 18
47 22
9 28
50 27
30 5
22 28
7 6
48 18
37 47
15 ...

output:

0

result:

ok single line: '0'

Test #38:

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

input:

100 100 4
4 1 3 3 4 3 4 2 4 3 2 1 2 2 3 2 4 2 2 3 4 1 4 3 4 3 2 3 2 3 1 4 1 4 1 1 1 1 1 1 1 3 4 4 3 1 1 2 1 1 4 2 4 4 3 3 2 1 4 2 2 3 2 3 2 1 2 3 2 4 1 1 4 3 1 1 1 4 2 3 1 3 2 3 4 3 3 4 2 2 1 1 1 2 4 2 4 4 2 1
91 30
94 91
38 91
72 91
23 91
91 4
91 33
91 18
91 41
91 14
91 5
39 91
100 91
50 91
91 6
43...

output:

3598

result:

ok single line: '3598'

Test #39:

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

input:

60 99 4
3 2 1 2 3 1 2 3 3 1 3 1 1 1 2 1 3 1 2 2 1 2 1 3 1 1 3 2 3 3 3 3 3 2 1 2 1 2 3 2 2 3 2 2 3 1 1 2 1 1 2 2 2 1 3 1 3 3 4 3
59 27
21 57
4 59
28 40
47 18
45 59
40 59
17 59
59 32
32 7
12 17
44 59
41 59
59 51
57 35
54 43
50 60
37 8
53 17
25 55
28 51
59 28
35 27
38 59
9 59
28 60
6 42
36 59
11 51
26 ...

output:

2406

result:

ok single line: '2406'

Test #40:

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

input:

100 100 4
4 2 3 1 2 4 4 1 4 4 4 4 4 3 1 1 2 1 1 4 4 3 3 3 2 1 3 3 3 1 1 2 1 4 2 3 4 3 2 2 3 2 3 1 3 4 2 1 2 2 4 2 3 2 3 3 1 2 2 2 4 1 4 3 2 1 3 1 4 4 2 2 2 2 4 3 2 4 2 1 1 3 1 3 4 4 2 1 2 4 3 4 3 2 1 2 1 4 4 4
45 72
77 72
25 27
13 14
92 25
33 70
94 71
82 24
100 66
72 64
88 11
73 16
16 40
19 10
31 26...

output:

316

result:

ok single line: '316'

Test #41:

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

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #42:

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

input:

3 3 3
1 3 2
3 1
1 2
2 3

output:

12

result:

ok single line: '12'

Subtask #4:

score: 30
Accepted

Dependency #1:

100%
Accepted

Test #43:

score: 30
Accepted
time: 3ms
memory: 13476kb

input:

2 1 5
5 3
1 2

output:

2

result:

ok single line: '2'

Test #44:

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

input:

480 100000 5
2 2 2 3 5 2 1 5 3 5 5 2 4 2 3 3 3 1 2 3 4 2 4 3 5 5 4 4 2 4 4 2 5 1 2 1 1 1 2 2 2 5 1 3 5 1 1 2 3 5 4 4 4 1 1 4 4 3 1 3 3 1 5 3 3 3 2 1 5 3 5 4 2 5 2 3 5 5 3 3 3 2 5 3 2 3 5 5 3 2 3 5 1 5 2 5 2 1 1 3 4 2 5 4 4 2 1 1 5 5 4 1 2 4 4 1 5 2 3 3 3 1 5 3 2 4 3 4 3 2 3 1 2 3 5 3 5 4 5 3 5 3 1 1...

output:

545258011824

result:

ok single line: '545258011824'

Test #45:

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

input:

100000 100000 5
4 2 3 3 5 1 2 5 5 5 1 3 4 5 2 3 2 3 4 2 2 4 4 5 1 3 3 5 5 1 2 5 5 5 5 3 3 4 5 1 2 3 4 4 5 4 2 5 3 2 4 3 4 5 2 2 1 2 5 5 4 1 5 4 4 5 5 3 4 5 3 2 2 4 5 4 3 4 2 4 2 4 4 5 3 3 4 5 3 2 5 1 4 5 4 4 4 4 5 5 3 1 5 1 4 5 2 3 5 2 4 1 2 4 1 1 3 3 3 3 5 5 1 1 2 2 1 2 5 4 5 2 3 1 5 4 2 3 1 4 3 2 ...

output:

564534

result:

ok single line: '564534'

Test #46:

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

input:

480 100000 3
3 2 3 3 2 2 1 1 3 2 2 1 2 1 1 2 1 2 1 3 1 1 3 1 2 2 2 2 3 1 2 2 1 2 1 3 1 3 2 2 1 2 2 3 3 1 2 1 3 1 1 3 2 1 3 2 2 3 1 3 2 3 3 2 3 1 1 1 1 3 2 2 2 3 2 2 3 2 3 3 1 1 3 3 1 3 2 3 1 3 3 2 3 1 1 3 2 2 3 1 1 2 2 2 3 1 1 1 2 3 1 3 2 2 2 1 1 2 1 1 1 3 1 2 1 1 2 3 3 3 3 1 1 2 3 3 3 3 2 3 2 3 3 2...

output:

18770760

result:

ok single line: '18770760'

Test #47:

score: 0
Accepted
time: 31ms
memory: 24176kb

input:

100000 100000 3
2 3 2 2 1 2 2 1 1 2 2 1 2 3 1 3 1 2 1 3 2 3 3 2 3 1 2 3 1 2 1 3 3 2 2 3 2 2 2 3 2 2 2 3 2 1 2 2 3 2 2 2 2 3 3 2 2 2 2 3 2 3 2 3 2 3 1 3 1 2 3 3 3 1 2 2 2 2 2 3 1 1 1 2 1 1 3 1 3 2 2 2 1 2 2 2 1 1 2 3 2 1 3 1 3 2 1 2 3 2 2 1 1 3 2 3 1 3 3 3 2 1 1 2 3 1 1 3 1 2 2 3 2 1 3 2 2 3 1 3 2 2 ...

output:

222836

result:

ok single line: '222836'

Test #48:

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

input:

100000 99999 3
1 2 2 2 3 1 1 3 1 2 1 1 2 2 2 3 3 1 1 1 1 2 2 3 1 1 1 2 2 2 3 1 2 1 3 1 3 3 2 2 2 2 2 1 2 2 2 2 1 2 3 3 3 1 3 3 3 1 3 2 1 1 2 1 3 3 1 3 3 2 1 1 3 1 1 1 3 2 3 2 1 3 1 3 1 1 1 1 1 3 3 2 3 2 1 3 2 3 3 2 2 2 1 3 1 2 3 2 2 2 1 3 1 2 1 3 3 3 1 3 1 3 3 2 3 1 3 1 3 2 2 2 2 1 1 3 1 2 2 1 3 2 2...

output:

2220366454

result:

ok single line: '2220366454'

Test #49:

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

input:

50000 89999 5
5 3 5 4 1 3 2 3 3 2 5 5 5 5 3 3 3 3 2 1 4 5 3 2 2 1 1 2 2 1 1 3 5 1 5 1 3 2 1 3 1 1 3 1 3 1 3 4 4 5 4 2 1 1 2 4 2 3 4 4 2 1 5 2 2 5 3 3 1 5 2 1 3 3 4 4 1 3 4 4 1 4 4 5 4 1 2 4 1 4 1 3 4 3 5 1 3 2 5 2 3 3 2 4 3 3 1 1 1 4 3 4 2 1 5 5 3 1 1 5 4 2 3 4 5 1 5 3 3 4 1 2 4 1 3 1 4 4 2 3 5 1 4 ...

output:

3454818410

result:

ok single line: '3454818410'

Test #50:

score: 0
Accepted
time: 20ms
memory: 33816kb

input:

480 100000 4
3 2 4 1 4 2 3 4 4 4 2 4 4 1 3 1 1 4 3 3 1 3 3 1 1 3 1 1 2 4 2 4 1 1 2 2 4 3 1 2 2 4 1 1 3 2 3 1 3 4 3 1 3 4 3 4 3 3 4 3 1 3 1 4 3 3 2 3 4 3 3 3 4 3 2 1 2 4 2 2 1 1 3 4 2 2 4 2 2 1 1 3 4 4 3 2 3 1 4 3 2 1 2 2 1 3 1 1 2 3 3 2 2 4 1 2 2 2 4 1 4 1 3 1 4 2 3 4 3 4 2 4 1 3 3 4 3 3 3 4 3 4 4 3...

output:

3277553092

result:

ok single line: '3277553092'

Test #51:

score: 0
Accepted
time: 29ms
memory: 39884kb

input:

100000 100000 4
1 1 1 1 3 3 4 1 4 4 2 3 1 1 2 4 4 1 3 1 4 3 2 2 2 3 3 4 3 4 3 2 4 2 1 1 3 3 4 4 1 4 1 2 3 1 1 4 4 2 4 2 1 4 4 2 1 1 2 2 2 3 3 1 1 3 4 3 4 1 1 3 4 1 4 2 1 1 3 4 3 4 1 3 1 2 3 4 2 1 4 4 2 2 1 3 2 2 3 4 4 3 1 4 2 1 2 2 4 4 2 3 3 4 3 2 1 4 4 3 3 2 3 3 2 1 1 1 4 2 1 4 1 4 3 4 3 4 1 3 2 4 ...

output:

374134

result:

ok single line: '374134'

Test #52:

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

input:

100000 99999 4
3 2 3 2 4 3 3 3 1 1 1 1 4 2 4 2 2 1 2 4 1 1 4 2 1 1 4 3 1 3 3 3 4 2 4 1 1 3 2 2 3 3 3 3 3 3 1 2 1 2 4 4 4 1 3 1 1 4 3 3 4 3 4 3 3 3 2 4 1 4 2 4 2 3 2 3 4 2 1 1 4 3 3 1 1 3 3 4 2 1 3 2 3 4 4 2 1 2 1 1 4 2 4 1 4 4 4 1 4 1 4 3 4 4 1 3 4 2 2 3 1 1 3 1 3 2 1 1 2 3 1 2 3 3 4 2 3 4 3 2 1 1 2...

output:

3760223314

result:

ok single line: '3760223314'

Test #53:

score: 0
Accepted
time: 38ms
memory: 32960kb

input:

100000 99999 4
2 4 2 3 3 4 2 4 3 2 2 2 3 3 3 2 4 2 2 2 4 4 4 4 4 2 3 3 4 4 4 4 3 4 4 2 4 2 3 4 4 2 4 2 2 4 3 2 4 4 3 3 3 3 3 3 3 3 3 3 4 3 2 4 2 3 2 2 4 2 3 4 4 2 2 2 4 4 2 2 4 4 2 2 2 3 3 3 3 2 3 4 4 2 3 3 4 2 3 3 4 4 4 4 2 3 2 2 2 2 4 3 3 4 4 3 3 4 4 4 2 2 3 3 3 4 2 2 2 2 3 3 2 4 2 2 2 3 3 4 4 4 4...

output:

4444622220

result:

ok single line: '4444622220'

Test #54:

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

input:

75000 99996 5
1 5 3 3 3 3 5 5 5 3 3 1 1 5 3 3 5 1 5 5 5 5 1 1 3 1 3 3 1 3 5 1 3 3 3 3 3 5 5 3 3 1 3 1 1 3 1 5 3 3 3 5 5 5 3 1 5 3 3 3 5 1 5 3 5 1 3 5 1 5 3 3 5 5 5 1 1 5 3 1 1 5 3 5 3 1 3 3 1 5 1 1 3 3 3 1 3 5 3 3 1 1 5 3 3 5 3 3 1 1 1 1 5 1 5 5 1 5 3 5 1 5 1 1 1 1 5 5 3 3 1 5 1 5 3 5 3 1 1 1 3 1 1 ...

output:

31252499849988

result:

ok single line: '31252499849988'

Test #55:

score: 0
Accepted
time: 38ms
memory: 61480kb

input:

50000 96664 5
4 5 1 4 1 4 5 1 1 4 1 5 4 5 1 1 4 4 4 4 1 4 1 1 4 1 4 5 1 5 5 4 5 5 4 5 4 4 1 4 5 5 4 4 4 5 5 1 4 1 5 1 4 5 4 4 5 1 1 4 5 5 4 5 4 5 1 5 4 5 5 1 4 5 1 4 5 1 4 1 1 1 4 1 5 1 5 4 1 5 1 4 1 5 5 1 4 5 1 5 1 1 5 1 5 1 1 4 4 4 5 1 1 4 4 1 1 5 1 5 1 1 1 4 1 4 5 1 1 5 5 4 4 5 4 4 5 5 1 1 4 4 4 ...

output:

9262597908028

result:

ok single line: '9262597908028'

Test #56:

score: 0
Accepted
time: 43ms
memory: 74788kb

input:

100000 100000 5
5 1 5 1 4 4 4 4 4 5 1 2 4 3 4 5 5 4 2 3 3 5 4 3 5 1 3 1 3 1 3 5 2 2 5 3 1 1 1 1 2 4 3 5 3 4 2 4 5 1 2 5 3 4 5 5 1 2 2 5 4 5 5 4 2 5 1 2 2 3 3 4 3 5 4 2 4 4 2 4 5 1 1 2 4 3 2 3 4 1 5 3 1 4 4 4 3 2 3 3 1 5 1 3 4 3 1 1 2 2 2 1 2 2 4 4 3 2 3 1 2 3 2 5 2 4 1 4 3 2 2 2 2 5 3 3 5 3 5 3 2 4 ...

output:

559300

result:

ok single line: '559300'

Test #57:

score: 0
Accepted
time: 33ms
memory: 77068kb

input:

100000 100000 5
1 2 2 3 2 3 5 1 4 3 4 4 2 1 4 5 2 4 2 5 5 3 5 3 3 3 4 2 5 1 5 2 1 5 5 4 2 3 3 5 2 5 4 1 1 4 1 2 3 2 5 2 3 4 3 3 4 1 5 4 4 3 5 4 4 3 3 2 4 1 3 4 4 4 3 1 5 2 1 1 1 4 2 2 5 5 2 3 5 1 2 2 4 1 1 2 5 2 1 3 5 5 1 4 3 2 1 5 4 2 5 2 3 2 2 3 2 2 3 1 4 3 1 4 4 1 5 2 3 4 2 5 2 2 3 5 5 1 2 2 1 1 ...

output:

398058

result:

ok single line: '398058'

Test #58:

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

input:

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

output:

1316

result:

ok single line: '1316'

Test #59:

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

input:

100 100 4
1 2 1 2 2 3 2 4 1 2 3 2 2 3 1 4 1 3 2 3 4 4 2 3 1 4 3 4 1 4 2 4 1 3 4 2 2 1 1 2 3 2 2 3 4 2 4 1 4 2 1 1 2 2 3 1 2 4 1 4 2 2 4 3 3 2 4 1 3 1 2 3 3 4 1 2 4 3 4 2 1 1 4 4 4 3 1 1 4 2 3 3 2 4 4 2 2 2 1 1
57 14
39 28
36 49
9 35
17 12
74 16
65 34
69 29
95 16
72 85
27 85
68 45
85 76
49 99
46 31
7...

output:

404

result:

ok single line: '404'

Test #60:

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

input:

50 100 3
2 1 1 1 1 1 1 1 2 3 2 1 2 3 2 3 2 2 2 2 3 2 3 3 1 1 1 2 3 1 3 1 2 1 3 3 1 2 1 3 3 1 2 1 2 3 2 2 2 2
25 13
16 25
35 25
33 8
48 42
15 16
36 33
5 4
16 32
31 34
19 28
6 30
39 43
50 19
10 50
13 15
13 29
30 18
46 21
39 35
45 8
43 14
23 48
26 23
1 35
47 32
13 22
29 24
40 32
21 38
30 44
44 46
33 6
...

output:

348

result:

ok single line: '348'

Test #61:

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

input:

50 100 2
2 1 2 1 2 2 1 1 1 2 1 1 1 2 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 2 2 2 1 2
37 11
3 45
26 21
26 33
16 49
25 7
21 14
43 48
21 40
4 11
30 34
40 43
5 21
12 32
34 42
38 4
2 15
4 1
41 45
49 48
30 8
42 20
34 44
50 5
5 49
34 16
50 33
41 15
18 47
23 8
37 19
48 26
19 33
11 36...

output:

94

result:

ok single line: '94'

Test #62:

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

input:

50 100 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41 25
26 50
33 20
38 35
22 25
14 50
12 15
20 19
23 8
44 50
22 42
9 50
39 21
26 20
44 23
24 31
12 28
23 49
25 14
43 37
2 24
8 19
26 11
43 5
9 18
47 22
9 28
50 27
30 5
22 28
7 6
48 18
37 47
15 ...

output:

0

result:

ok single line: '0'

Test #63:

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

input:

100 100 4
4 1 3 3 4 3 4 2 4 3 2 1 2 2 3 2 4 2 2 3 4 1 4 3 4 3 2 3 2 3 1 4 1 4 1 1 1 1 1 1 1 3 4 4 3 1 1 2 1 1 4 2 4 4 3 3 2 1 4 2 2 3 2 3 2 1 2 3 2 4 1 1 4 3 1 1 1 4 2 3 1 3 2 3 4 3 3 4 2 2 1 1 1 2 4 2 4 4 2 1
91 30
94 91
38 91
72 91
23 91
91 4
91 33
91 18
91 41
91 14
91 5
39 91
100 91
50 91
91 6
43...

output:

3598

result:

ok single line: '3598'

Test #64:

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

input:

60 99 4
3 2 1 2 3 1 2 3 3 1 3 1 1 1 2 1 3 1 2 2 1 2 1 3 1 1 3 2 3 3 3 3 3 2 1 2 1 2 3 2 2 3 2 2 3 1 1 2 1 1 2 2 2 1 3 1 3 3 4 3
59 27
21 57
4 59
28 40
47 18
45 59
40 59
17 59
59 32
32 7
12 17
44 59
41 59
59 51
57 35
54 43
50 60
37 8
53 17
25 55
28 51
59 28
35 27
38 59
9 59
28 60
6 42
36 59
11 51
26 ...

output:

2406

result:

ok single line: '2406'

Test #65:

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

input:

100 100 4
4 2 3 1 2 4 4 1 4 4 4 4 4 3 1 1 2 1 1 4 4 3 3 3 2 1 3 3 3 1 1 2 1 4 2 3 4 3 2 2 3 2 3 1 3 4 2 1 2 2 4 2 3 2 3 3 1 2 2 2 4 1 4 3 2 1 3 1 4 4 2 2 2 2 4 3 2 4 2 1 1 3 1 3 4 4 2 1 2 4 3 4 3 2 1 2 1 4 4 4
45 72
77 72
25 27
13 14
92 25
33 70
94 71
82 24
100 66
72 64
88 11
73 16
16 40
19 10
31 26...

output:

316

result:

ok single line: '316'

Test #66:

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

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #67:

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

input:

3 3 3
1 3 2
3 1
1 2
2 3

output:

12

result:

ok single line: '12'