QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#566231#44. Paths3un_larryfunc100 ✓215ms95816kbC++23912b2024-09-15 23:27:592024-09-15 23:28:00

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 23
Accepted

Test #1:

score: 23
Accepted
time: 1ms
memory: 5668kb

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: 23
Accepted
time: 1ms
memory: 5676kb

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: 23
Accepted
time: 1ms
memory: 5744kb

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: 23
Accepted
time: 0ms
memory: 3700kb

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: 23
Accepted
time: 1ms
memory: 3708kb

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: 23
Accepted
time: 1ms
memory: 3640kb

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: 23
Accepted
time: 1ms
memory: 3620kb

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: 23
Accepted
time: 1ms
memory: 3724kb

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: 23
Accepted
time: 1ms
memory: 5652kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #10:

score: 23
Accepted
time: 1ms
memory: 5700kb

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: 36ms
memory: 12036kb

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: 20
Accepted
time: 31ms
memory: 7132kb

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: 20
Accepted
time: 134ms
memory: 95220kb

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: 20
Accepted
time: 53ms
memory: 16620kb

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: 20
Accepted
time: 46ms
memory: 19492kb

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: 20
Accepted
time: 88ms
memory: 69220kb

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: 20
Accepted
time: 117ms
memory: 95252kb

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: 20
Accepted
time: 131ms
memory: 95816kb

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: 40ms
memory: 8760kb

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: 27
Accepted
time: 31ms
memory: 7224kb

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: 27
Accepted
time: 144ms
memory: 95168kb

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: 27
Accepted
time: 55ms
memory: 19308kb

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: 27
Accepted
time: 47ms
memory: 17168kb

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: 27
Accepted
time: 101ms
memory: 66676kb

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: 27
Accepted
time: 133ms
memory: 95276kb

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: 27
Accepted
time: 130ms
memory: 95808kb

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: 27
Accepted
time: 27ms
memory: 7164kb

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: 27
Accepted
time: 48ms
memory: 11584kb

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: 27
Accepted
time: 204ms
memory: 95280kb

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: 27
Accepted
time: 117ms
memory: 52668kb

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: 27
Accepted
time: 133ms
memory: 54356kb

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: 27
Accepted
time: 215ms
memory: 95228kb

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: 27
Accepted
time: 1ms
memory: 3620kb

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: 27
Accepted
time: 1ms
memory: 5764kb

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: 27
Accepted
time: 1ms
memory: 3704kb

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: 27
Accepted
time: 1ms
memory: 5664kb

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: 27
Accepted
time: 1ms
memory: 3692kb

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: 27
Accepted
time: 1ms
memory: 5740kb

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: 27
Accepted
time: 1ms
memory: 5724kb

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: 27
Accepted
time: 1ms
memory: 5756kb

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: 27
Accepted
time: 1ms
memory: 5724kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #42:

score: 27
Accepted
time: 1ms
memory: 3668kb

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

input:

2 1 5
5 3
1 2

output:

2

result:

ok single line: '2'

Test #44:

score: 30
Accepted
time: 7ms
memory: 6540kb

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: 30
Accepted
time: 72ms
memory: 35100kb

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: 30
Accepted
time: 7ms
memory: 6636kb

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: 30
Accepted
time: 32ms
memory: 36480kb

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: 30
Accepted
time: 30ms
memory: 35880kb

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: 30
Accepted
time: 46ms
memory: 20588kb

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: 30
Accepted
time: 8ms
memory: 6628kb

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: 30
Accepted
time: 44ms
memory: 35120kb

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: 30
Accepted
time: 41ms
memory: 35604kb

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: 30
Accepted
time: 43ms
memory: 35596kb

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: 30
Accepted
time: 49ms
memory: 29404kb

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: 30
Accepted
time: 44ms
memory: 21124kb

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: 30
Accepted
time: 70ms
memory: 36460kb

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: 30
Accepted
time: 75ms
memory: 36320kb

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: 30
Accepted
time: 1ms
memory: 3620kb

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: 30
Accepted
time: 1ms
memory: 5676kb

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: 30
Accepted
time: 1ms
memory: 3624kb

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: 30
Accepted
time: 1ms
memory: 3752kb

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: 30
Accepted
time: 1ms
memory: 5784kb

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: 30
Accepted
time: 1ms
memory: 3676kb

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: 30
Accepted
time: 1ms
memory: 5736kb

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: 30
Accepted
time: 1ms
memory: 5680kb

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: 30
Accepted
time: 0ms
memory: 5644kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #67:

score: 30
Accepted
time: 0ms
memory: 5660kb

input:

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

output:

12

result:

ok single line: '12'