QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#825248#9769. Rolling Stonesucup-team3925#AC ✓153ms22488kbC++173.8kb2024-12-21 17:52:012024-12-21 17:52:06

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 9964kb

input:

3
4
3 2 3
4 3 2 1 3
3 1

output:

6

result:

ok 1 number(s): "6"

Test #2:

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

input:

3
4
3 3 3
4 3 2 1 3
3 1

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

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

input:

2
4
1 3 3
2 3

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

2
4
1 2 3
2 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 153ms
memory: 22232kb

input:

100
4
1 2 3
4 3 1 1 4
1 3 3 4 1 2 3
2 2 2 1 2 2 2 4 4
4 1 2 4 2 1 4 2 1 2 2
4 3 3 1 2 4 2 1 4 4 2 3 4
3 2 3 1 1 4 2 4 3 2 3 4 1 4 3
4 4 2 1 3 3 2 1 4 3 3 3 4 3 2 1 2
1 2 4 3 1 1 4 4 1 2 3 3 4 1 3 4 2 2 2
1 3 2 2 4 3 4 1 4 3 2 2 4 3 2 1 4 4 2 1 3
3 2 2 4 4 4 1 4 1 2 3 1 3 2 3 4 1 2 3 4 1 1 3
2 2 4 2 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #6:

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

input:

100
4
1 3 3
2 3 2 1 4
1 1 1 4 1 4 3
4 2 2 1 4 3 2 1 4
4 3 3 4 1 2 2 4 3 4 2
4 3 2 1 1 2 2 1 4 4 2 1 2
1 2 3 4 1 2 1 4 4 4 3 4 1 4 3
1 3 4 2 3 4 3 1 4 2 2 1 4 1 1 3 4
2 2 3 4 3 2 2 4 4 1 3 4 2 2 3 4 3 1 3
3 3 3 2 4 3 2 2 4 3 1 1 4 3 1 1 4 1 2 2 3
1 2 2 4 3 2 3 3 2 4 3 4 1 2 2 4 3 1 4 4 1 2 3
4 4 4 2 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #7:

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

input:

100
4
1 2 3
4 3 2 1 4
1 2 2 3 1 1 4
2 3 4 2 4 3 2 3 4
4 2 3 4 1 2 3 1 1 2 3
1 3 1 3 4 4 2 1 2 1 2 3 4
2 1 1 4 1 1 3 4 2 3 3 4 1 2 3
1 1 2 1 1 3 2 1 1 3 2 1 1 3 2 3 4
2 2 1 4 1 2 2 4 1 4 2 2 1 1 3 3 1 4 3
4 2 2 4 4 3 2 1 4 3 2 2 1 4 2 1 4 3 4 2 4
1 2 3 3 1 2 3 2 1 2 3 4 2 1 3 4 4 3 3 2 1 2 3
2 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

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

input:

100
4
1 1 4
4 3 2 1 4
3 2 1 4 1 4 3
1 3 3 1 2 2 3 3 3
1 2 3 1 1 2 3 2 1 1 1
1 3 2 1 4 3 2 1 4 3 2 1 1
2 2 3 3 3 2 3 4 4 3 3 4 1 3 4
4 3 2 3 4 1 2 1 4 3 1 1 2 2 1 1 1
1 2 3 2 1 1 2 4 3 2 3 4 1 2 3 4 1 3 3
4 4 3 2 4 3 2 3 3 3 3 2 4 3 2 1 3 3 2 1 4
2 2 3 4 1 2 3 4 3 2 3 4 3 2 3 4 4 2 1 4 1 2 3
4 3 4 4 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #9:

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

input:

100
4
1 4 3
4 3 3 1 4
1 2 3 4 1 2 3
1 3 1 1 4 3 2 1 4
1 2 3 2 2 1 1 4 3 2 4
4 3 1 3 4 3 3 2 2 3 1 3 2
3 2 4 4 1 2 3 3 1 4 3 4 1 3 1
4 4 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 3 1 3 4 1 2 1 4 1 2 3 4 1 1 3
2 3 2 1 2 3 2 1 4 4 2 1 2 3 2 1 4 3 1 1 4
1 2 4 4 1 3 3 4 1 2 2 4 1 2 3 4 4 4 3 2 1 2 1
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #10:

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

input:

100
4
4 1 3
4 3 2 1 1
4 2 2 4 1 2 4
2 3 1 2 1 3 2 1 4
1 3 3 4 1 2 1 4 1 4 3
3 3 2 1 1 3 2 2 4 3 2 1 4
1 2 3 1 1 2 3 4 1 3 3 3 1 2 1
4 1 2 1 4 3 2 1 4 2 2 1 4 3 2 1 4
2 4 3 2 1 2 3 2 1 3 3 4 2 2 3 4 1 2 3
4 3 2 1 4 2 2 2 4 3 2 1 4 2 2 1 3 3 4 4 4
1 2 3 1 3 2 3 4 2 2 3 4 1 2 3 4 1 2 2 4 1 3 1
4 3 2 2 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #11:

score: 0
Accepted
time: 143ms
memory: 22196kb

input:

100
4
1 2 3
1 3 2 1 2
1 2 2 4 4 4 3
2 3 2 3 4 3 2 1 4
1 2 4 4 1 2 1 4 1 4 3
2 3 1 1 2 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 4 3 4 3 2 3
4 3 2 1 4 3 2 2 4 3 2 1 4 3 2 1 4
1 2 3 4 1 1 3 4 4 3 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 4 1 1 3 3 2 4 4 2 1 4 3 2 3 3
1 2 3 4 1 2 4 4 1 2 1 4 1 2 3 3 4 3 2 4 1 3 3
2 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #12:

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

input:

100
4
4 2 3
4 3 2 1 3
1 3 2 4 1 2 3
4 3 2 1 3 3 4 1 3
1 2 3 1 1 1 3 1 1 2 3
4 3 2 1 4 3 2 1 4 3 2 4 1
1 2 3 4 1 2 4 4 1 3 2 4 1 4 1
3 1 2 2 4 3 4 1 1 1 2 3 4 3 2 1 4
3 2 4 2 2 2 2 1 3 2 3 1 1 1 3 4 1 2 3
4 3 2 2 4 2 2 3 4 2 2 1 4 3 2 1 4 3 2 4 3
1 2 4 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 2
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #13:

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

input:

100
4
1 2 3
4 3 2 4 4
1 2 3 4 4 2 3
4 3 2 4 4 3 3 1 4
3 1 3 4 1 2 3 4 1 2 1
4 3 2 1 4 3 2 1 4 4 3 1 4
1 2 3 4 1 2 3 4 1 2 3 1 1 4 3
4 1 2 3 4 3 2 1 4 3 2 1 4 4 3 1 3
1 2 1 4 2 2 4 4 1 2 3 4 1 2 3 3 2 2 3
4 1 3 1 4 3 2 2 4 1 2 1 3 3 2 1 4 1 2 3 4
1 2 3 4 3 3 1 4 1 2 3 1 1 2 3 4 1 2 3 3 1 2 3
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #14:

score: 0
Accepted
time: 147ms
memory: 22092kb

input:

100
4
1 2 1
2 2 2 1 4
2 2 3 4 1 2 3
4 4 2 2 4 3 2 1 4
1 2 3 3 1 2 1 4 1 2 1
4 3 2 3 4 3 2 1 4 3 2 1 4
1 2 1 4 1 2 3 4 1 2 3 4 1 2 3
2 1 2 1 4 3 2 1 3 4 2 1 4 3 2 1 4
2 3 3 3 1 2 2 4 1 2 3 4 1 3 4 4 2 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 4 3 1 2 3 4 1 4 3 4 4 2 3 2 1 2 3 4 1 3 2
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #15:

score: 0
Accepted
time: 139ms
memory: 22184kb

input:

100
4
1 2 3
4 3 2 2 4
1 2 2 4 1 2 3
4 3 4 1 4 2 2 1 4
1 2 1 4 1 2 3 4 3 2 3
4 3 2 1 4 3 2 1 4 4 3 2 4
2 2 3 4 1 2 2 4 3 2 3 3 1 1 2
4 3 2 1 4 3 2 1 4 2 2 1 4 1 2 1 1
1 1 3 4 1 3 1 4 2 2 3 4 3 2 3 4 1 2 3
4 3 2 1 4 1 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
3 2 3 4 1 2 3 4 1 3 3 3 1 4 3 1 1 2 3 4 1 2 3
4 4 2 1 ...

output:

86

result:

ok 1 number(s): "86"

Test #16:

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

input:

100
4
1 2 3
1 3 2 1 4
1 2 3 4 2 2 3
4 1 2 1 3 3 2 3 4
3 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 2 4 1 2 1 4
1 2 3 4 1 2 1 4 1 2 3 4 2 2 3
4 2 2 1 4 3 2 2 4 3 2 1 3 3 2 1 4
1 2 3 3 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 4 2 1 4 3 2 1 4
1 2 3 4 4 2 3 4 1 2 3 4 1 2 3 2 1 2 4 1 1 2 3
4 3 3 1 ...

output:

207

result:

ok 1 number(s): "207"

Test #17:

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

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 4 1 2 3
4 3 4 1 4 1 2 1 4
1 2 3 4 1 2 3 3 1 2 3
4 3 2 1 2 3 2 3 4 3 2 1 4
1 2 3 4 4 2 4 4 1 2 3 1 1 2 3
4 3 2 1 4 1 2 1 4 3 2 1 4 3 2 1 1
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 3 1 4 3 2 1 4 3 2 1 1 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 3 3
4 3 1 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #18:

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

input:

100
4
1 2 3
4 3 2 2 2
1 4 3 4 1 2 3
4 3 2 1 4 3 2 1 3
1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 2
1 2 4 1 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 3 3 4 1 3 3 2 1 4 3 1 1 4
1 2 3 4 1 2 1 4 2 2 3 3 1 2 3 4 1 2 3
1 1 2 1 4 3 2 1 4 2 1 1 4 3 2 1 4 3 2 1 4
1 2 1 4 2 4 3 4 1 2 3 4 1 4 3 4 1 2 3 4 1 1 3
4 3 2 1 ...

output:

143

result:

ok 1 number(s): "143"

Test #19:

score: 0
Accepted
time: 143ms
memory: 22292kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 1 4 1 2 3
4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 3 2 3
4 3 1 3 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 1 4 1 2 3
1 3 2 1 4 3 2 1 4 3 1 4 4 3 2 1 4
1 2 3 4 1 4 3 4 1 2 3 4 1 2 3 4 4 2 4
3 3 2 1 4 3 2 4 4 3 2 1 4 4 1 1 4 3 2 1 4
1 2 3 4 1 1 3 4 1 2 3 1 1 2 2 4 1 2 3 4 1 2 3
4 3 2 1 ...

output:

179

result:

ok 1 number(s): "179"

Test #20:

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

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 2 1 2 2
4 3 2 1 2 1 2 1 4
1 2 3 4 1 2 3 4 1 3 3
4 3 2 1 4 3 2 4 4 3 2 1 4
2 2 3 4 1 2 3 4 1 3 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 4 2 3 4 1 2 3 4 1 2 2 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 2 4 1 2 3 4 3 2 3 4 1 2 3 4 1 2 3 4 2 4 3
4 3 2 1 ...

output:

2

result:

ok 1 number(s): "2"

Test #21:

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

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 4 1 2 3
4 3 2 4 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 1 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 2 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 4 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #22:

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

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4
1 3 3 4 1 2 3 4 1 2 3
4 3 2 2 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 3 2 3 4 2 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 3
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 4 3 4 1 2 3 3 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 ...

output:

160

result:

ok 1 number(s): "160"

Test #23:

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

input:

100
4
1 2 3
4 3 1 1 4
1 2 3 4 1 3 3
4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 4
4 3 2 1 4 3 2 1 4 3 2 1 2 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 3 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 1 3 4 1 2 3 4 1 2 3 4 1 4 3
4 3 2 1 ...

output:

24

result:

ok 1 number(s): "24"

Test #24:

score: 0
Accepted
time: 139ms
memory: 22296kb

input:

100
4
1 2 3
4 3 2 1 4
1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 4 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 3 1 2 3 4 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 4 4 3 2 1 4
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3
4 3 2 1 ...

output:

131

result:

ok 1 number(s): "131"

Test #25:

score: 0
Accepted
time: 147ms
memory: 22168kb

input:

100
4
1 2 3
4 3 2 4 4
1 2 2 4 1 2 3
4 4 2 1 4 2 2 1 4
1 2 3 4 4 2 3 4 4 2 3
4 3 2 2 4 3 2 2 4 3 2 3 4
1 2 2 4 1 2 1 4 1 2 4 4 1 2 3
4 2 2 1 4 4 2 1 4 4 2 1 4 1 2 1 4
1 2 3 4 3 2 3 4 3 2 3 4 3 2 3 4 2 2 3
4 3 2 4 4 3 2 4 4 3 2 2 4 3 2 3 4 3 2 2 4
1 2 2 4 1 2 4 4 1 2 4 4 1 2 4 4 1 2 4 4 1 2 3
4 2 2 1 ...

output:

7352

result:

ok 1 number(s): "7352"

Test #26:

score: 0
Accepted
time: 147ms
memory: 22444kb

input:

100
4
1 2 2
4 3 2 1 4
4 1 4 1 3 2 3
4 3 2 1 4 3 2 1 4
1 2 2 1 4 4 1 2 3 3 2
4 3 2 1 4 3 2 1 4 3 2 1 4
3 3 1 3 3 3 1 3 2 1 2 1 3 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 1 1 4 1 1 3 3 4 1 2 3 1 2 3 3 1 2
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
2 4 2 3 3 3 1 2 2 3 1 3 4 1 1 3 3 1 1 1 4 2 3
4 3 2 1 ...

output:

4996

result:

ok 1 number(s): "4996"

Test #27:

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

input:

100
4
1 2 3
4 3 2 4 4
1 2 1 4 1 2 3
4 4 2 1 4 1 2 1 4
1 2 3 4 4 2 3 4 3 2 3
4 3 2 4 4 3 2 2 4 3 2 3 4
1 2 2 4 1 2 1 4 1 2 2 4 1 2 3
4 4 2 1 4 4 2 1 4 1 2 1 4 2 2 1 4
1 2 3 4 3 2 3 4 4 2 3 4 4 2 3 4 2 2 3
4 3 2 4 4 3 2 2 4 3 2 2 4 3 2 2 4 3 2 3 4
1 2 4 4 1 2 1 4 1 2 2 4 1 2 2 4 1 2 2 4 1 2 3
4 2 2 1 ...

output:

3736

result:

ok 1 number(s): "3736"

Test #28:

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

input:

100
4
1 2 1
4 3 2 1 4
2 1 4 1 3 2 3
4 3 2 1 4 3 2 1 4
1 2 1 2 2 4 2 1 4 1 4
4 3 2 1 4 3 2 1 4 3 2 1 4
2 1 1 2 4 1 1 1 4 4 1 3 3 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 4 3 3 4 2 2 2 4 4 1 4 3 1 3 3 1 2
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
4 1 3 1 4 4 1 1 2 4 1 2 3 4 4 2 3 1 1 2 2 2 3
4 3 2 1 ...

output:

4716

result:

ok 1 number(s): "4716"

Test #29:

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

input:

100
4
1 2 3
4 3 2 4 4
1 2 1 4 1 2 3
4 1 2 1 4 2 2 1 4
1 2 3 4 4 2 3 4 4 2 3
4 3 2 2 4 3 2 4 4 3 2 4 4
1 2 2 4 1 2 1 4 1 2 1 4 1 2 3
4 2 2 1 4 4 2 1 4 1 2 1 4 1 2 1 4
1 2 3 4 4 2 3 4 4 2 3 4 4 2 3 4 4 2 3
4 3 2 3 4 3 2 3 4 3 2 4 4 3 2 4 4 3 2 3 4
1 2 1 4 1 2 2 4 1 2 4 4 1 2 4 4 1 2 1 4 1 2 3
4 2 2 1 ...

output:

2255

result:

ok 1 number(s): "2255"

Test #30:

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

input:

100
4
1 2 2
4 3 2 1 4
3 1 4 1 4 2 3
4 3 2 1 4 3 2 1 4
1 2 1 3 2 4 2 3 4 3 1
4 3 2 1 4 3 2 1 4 3 2 1 4
1 1 2 3 2 4 2 1 4 2 1 3 1 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 1 1 3 3 1 2 4 1 4 2 4 4 2 2 2 3 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
3 4 1 4 4 3 1 3 2 1 4 1 2 3 4 1 4 4 4 1 1 2 3
4 3 2 1 ...

output:

3598

result:

ok 1 number(s): "3598"

Test #31:

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

input:

100
4
1 2 3
4 3 2 4 4
1 2 2 4 1 2 3
4 2 2 1 4 4 2 1 4
1 2 3 4 2 2 3 4 3 2 3
4 3 2 3 4 3 2 4 4 3 2 3 4
1 2 4 4 1 2 2 4 1 2 2 4 1 2 3
4 4 2 1 4 4 2 1 4 1 2 1 4 1 2 1 4
1 2 3 4 3 2 3 4 3 2 3 4 3 2 3 4 3 2 3
4 3 2 4 4 3 2 3 4 3 2 2 4 3 2 4 4 3 2 4 4
1 2 2 4 1 2 1 4 1 2 3 4 1 2 4 4 1 2 1 4 1 2 3
4 1 2 1 ...

output:

2458

result:

ok 1 number(s): "2458"

Test #32:

score: 0
Accepted
time: 147ms
memory: 22264kb

input:

100
4
1 2 1
4 3 2 1 4
4 1 2 1 2 2 3
4 3 2 1 4 3 2 1 4
1 2 4 2 4 1 3 3 2 1 4
4 3 2 1 4 3 2 1 4 3 2 1 4
4 1 1 2 2 4 2 1 2 4 4 1 2 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 2 2 2 3 1 4 2 4 4 4 4 2 1 2 4 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
2 4 2 2 4 3 1 1 3 2 4 1 2 4 4 1 3 3 4 1 3 2 3
4 3 2 1 ...

output:

2009

result:

ok 1 number(s): "2009"

Test #33:

score: 0
Accepted
time: 147ms
memory: 22160kb

input:

100
4
1 2 3
4 3 2 2 4
1 2 4 4 1 2 3
4 2 2 1 4 1 2 1 4
1 2 3 4 4 2 3 4 2 2 3
4 3 2 2 4 3 2 4 4 3 2 4 4
1 2 4 4 1 2 4 4 1 2 2 4 1 2 3
4 1 2 1 4 2 2 1 4 2 2 1 4 4 2 1 4
1 2 3 4 3 2 3 4 4 2 3 4 3 2 3 4 2 2 3
4 3 2 4 4 3 2 2 4 3 2 4 4 3 2 4 4 3 2 2 4
1 2 1 4 1 2 1 4 1 2 2 4 1 2 4 4 1 2 4 4 1 2 3
4 2 2 1 ...

output:

1638

result:

ok 1 number(s): "1638"

Test #34:

score: 0
Accepted
time: 152ms
memory: 22260kb

input:

100
4
1 2 2
4 3 2 1 4
1 1 4 3 2 2 3
4 3 2 1 4 3 2 1 4
1 2 3 3 3 1 2 1 3 1 3
4 3 2 1 4 3 2 1 4 3 2 1 4
4 4 2 3 4 2 2 4 2 1 4 2 3 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
1 2 3 4 3 3 4 3 4 2 3 3 2 1 4 2 2 2 3
4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 4
2 3 3 2 3 3 2 4 3 2 3 1 2 2 2 3 1 2 4 4 4 2 3
4 3 2 1 ...

output:

1723

result:

ok 1 number(s): "1723"

Test #35:

score: 0
Accepted
time: 143ms
memory: 22124kb

input:

100
4
1 2 3
3 3 2 4 4
1 2 3 4 4 2 3
1 3 2 4 4 3 2 1 4
1 2 3 4 2 2 3 2 1 2 3
3 3 2 2 4 3 2 1 2 3 2 4 4
1 2 3 4 2 2 3 2 1 2 3 4 4 2 3
3 3 2 4 4 3 2 1 1 3 2 2 4 3 2 1 4
1 2 3 4 4 2 3 3 1 2 3 4 2 2 3 2 1 2 3
1 3 2 4 4 3 2 1 3 3 2 2 4 3 2 1 2 3 2 2 4
1 2 3 4 2 2 3 2 1 2 3 4 4 2 3 1 1 2 3 4 3 2 3
1 3 2 3 ...

output:

7352

result:

ok 1 number(s): "7352"

Test #36:

score: 0
Accepted
time: 139ms
memory: 22488kb

input:

100
4
2 2 3
1 2 2 1 3
4 4 3 4 2 3 3
3 2 2 1 3 2 2 1 4
4 3 3 4 4 4 3 4 4 2 3
1 4 2 1 3 2 2 1 2 4 2 1 3
3 4 3 4 2 3 3 4 2 3 3 4 4 4 3
2 4 2 1 3 1 2 1 3 1 2 1 1 1 2 1 4
4 4 3 4 2 3 3 4 4 3 3 4 4 4 3 4 4 2 3
1 4 2 1 1 4 2 1 3 4 2 1 2 1 2 1 2 4 2 1 2
4 1 3 4 3 4 3 4 2 1 3 4 4 4 3 4 4 1 3 4 4 1 3
1 4 2 1 ...

output:

4998

result:

ok 1 number(s): "4998"

Test #37:

score: 0
Accepted
time: 143ms
memory: 22196kb

input:

100
4
1 2 3
1 3 2 4 4
1 2 3 4 4 2 3
2 3 2 4 4 3 2 1 4
1 2 3 4 3 2 3 4 1 2 3
1 3 2 2 4 3 2 1 1 3 2 4 4
1 2 3 4 2 2 3 2 1 2 3 4 3 2 3
3 3 2 2 4 3 2 1 2 3 2 4 4 3 2 1 4
1 2 3 4 4 2 3 1 1 2 3 4 2 2 3 3 1 2 3
2 3 2 2 4 3 2 1 2 3 2 2 4 3 2 1 1 3 2 2 4
1 2 3 4 2 2 3 3 1 2 3 4 4 2 3 2 1 2 3 4 3 2 3
1 3 2 3 ...

output:

3288

result:

ok 1 number(s): "3288"

Test #38:

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

input:

100
4
1 2 3
1 2 2 1 2
3 4 3 4 4 1 3
2 3 2 1 2 4 2 1 4
3 1 3 4 4 3 3 4 4 2 3
3 2 2 1 3 2 2 1 2 4 2 1 3
3 1 3 4 4 3 3 4 4 1 3 4 2 4 3
2 1 2 1 2 2 2 1 2 2 2 1 3 2 2 1 4
2 1 3 4 3 3 3 4 3 1 3 4 4 4 3 4 3 2 3
2 1 2 1 2 1 2 1 2 4 2 1 3 4 2 1 1 4 2 1 1
2 1 3 4 1 4 3 4 3 4 3 4 3 4 3 4 2 4 3 4 3 3 3
2 2 2 1 ...

output:

4607

result:

ok 1 number(s): "4607"

Test #39:

score: 0
Accepted
time: 151ms
memory: 22232kb

input:

100
4
1 2 3
1 3 2 2 4
1 2 3 4 2 2 3
3 3 2 2 4 3 2 1 4
1 2 3 4 3 2 3 2 1 2 3
1 3 2 3 4 3 2 1 1 3 2 3 4
1 2 3 4 2 2 3 1 1 2 3 4 3 2 3
1 3 2 2 4 3 2 1 2 3 2 2 4 3 2 1 4
1 2 3 4 2 2 3 1 1 2 3 4 4 2 3 2 1 2 3
1 3 2 3 4 3 2 1 4 3 2 3 4 3 2 1 2 3 2 3 4
1 2 3 4 3 2 3 1 1 2 3 4 3 2 3 2 1 2 3 4 2 2 3
2 3 2 3 ...

output:

2271

result:

ok 1 number(s): "2271"

Test #40:

score: 0
Accepted
time: 151ms
memory: 22320kb

input:

100
4
4 2 3
2 2 2 1 3
2 4 3 4 2 4 3
1 2 2 1 3 2 2 1 4
2 1 3 4 3 4 3 4 2 2 3
2 4 2 1 3 1 2 1 1 2 2 1 1
2 1 3 4 1 3 3 4 4 4 3 4 2 3 3
3 4 2 1 3 4 2 1 1 1 2 1 2 1 2 1 4
4 3 3 4 4 1 3 4 3 1 3 4 3 4 3 4 2 2 3
3 4 2 1 1 1 2 1 2 4 2 1 3 4 2 1 2 1 2 1 2
3 1 3 4 2 4 3 4 4 3 3 4 4 4 3 4 2 1 3 4 4 4 3
2 2 2 1 ...

output:

2950

result:

ok 1 number(s): "2950"

Test #41:

score: 0
Accepted
time: 143ms
memory: 22396kb

input:

100
4
1 2 3
1 3 2 4 4
1 2 3 4 3 2 3
1 3 2 2 4 3 2 1 4
1 2 3 4 4 2 3 1 1 2 3
2 3 2 3 4 3 2 1 3 3 2 2 4
1 2 3 4 3 2 3 3 1 2 3 4 3 2 3
3 3 2 3 4 3 2 1 3 3 2 2 4 3 2 1 4
1 2 3 4 4 2 3 1 1 2 3 4 3 2 3 2 1 2 3
1 3 2 2 4 3 2 1 3 3 2 4 4 3 2 1 1 3 2 4 4
1 2 3 4 2 2 3 3 1 2 3 4 4 2 3 1 1 2 3 4 2 2 3
1 3 2 3 ...

output:

1618

result:

ok 1 number(s): "1618"

Test #42:

score: 0
Accepted
time: 143ms
memory: 22244kb

input:

100
4
2 2 3
2 2 2 1 1
2 1 3 4 2 4 3
4 1 2 1 2 3 2 1 4
2 3 3 4 4 3 3 4 3 2 3
2 1 2 1 2 1 2 1 3 4 2 1 3
1 1 3 4 4 3 3 4 2 3 3 4 4 3 3
3 1 2 1 2 3 2 1 4 4 2 1 3 1 2 1 4
4 3 3 4 3 4 3 4 2 4 3 4 3 4 3 4 4 2 3
1 1 2 1 3 1 2 1 1 2 2 1 4 2 2 1 1 4 2 1 4
2 4 3 4 4 4 3 4 3 4 3 4 2 4 3 4 4 3 3 4 1 1 3
4 4 2 1 ...

output:

2054

result:

ok 1 number(s): "2054"

Test #43:

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

input:

100
4
1 2 3
3 3 2 4 4
1 2 3 4 2 2 3
4 3 2 2 4 3 2 1 4
1 2 3 4 2 2 3 1 1 2 3
4 3 2 4 4 3 2 1 2 3 2 3 4
1 2 3 4 2 2 3 3 1 2 3 4 4 2 3
3 3 2 2 4 3 2 1 1 3 2 3 4 3 2 1 4
1 2 3 4 3 2 3 1 1 2 3 4 3 2 3 3 1 2 3
1 3 2 4 4 3 2 1 3 3 2 4 4 3 2 1 2 3 2 4 4
1 2 3 4 3 2 3 2 1 2 3 4 3 2 3 1 1 2 3 4 2 2 3
1 3 2 2 ...

output:

1217

result:

ok 1 number(s): "1217"

Test #44:

score: 0
Accepted
time: 147ms
memory: 22172kb

input:

100
4
2 2 3
1 1 2 1 1
1 3 3 4 2 1 3
3 2 2 1 1 4 2 1 4
1 1 3 4 4 3 3 4 3 2 3
1 4 2 1 2 2 2 1 3 1 2 1 1
2 1 3 4 2 3 3 4 4 3 3 4 3 1 3
1 1 2 1 3 4 2 1 2 2 2 1 3 4 2 1 4
3 3 3 4 1 1 3 4 4 4 3 4 4 1 3 4 3 2 3
3 1 2 1 3 4 2 1 3 2 2 1 2 3 2 1 4 1 2 1 2
2 3 3 4 4 4 3 4 4 3 3 4 4 1 3 4 3 3 3 4 4 1 3
4 2 2 1 ...

output:

1546

result:

ok 1 number(s): "1546"

Test #45:

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

input:

100
4
3 2 3
4 3 2 1 3
1 2 1 1 1 2 3
2 3 2 1 4 1 2 1 2
1 2 3 3 1 2 2 4 1 2 3
4 4 2 1 4 3 1 2 3 4 2 1 4
1 2 4 4 1 1 3 4 1 4 3 4 1 3 3
4 3 2 3 4 3 4 1 3 3 2 1 2 3 2 1 2
1 2 3 3 1 2 2 3 3 1 2 4 2 2 3 4 1 2 3
4 3 3 1 2 3 2 1 4 4 2 1 4 3 2 2 4 3 1 1 4
1 2 3 1 1 2 3 1 2 2 3 4 4 4 3 4 1 1 3 4 2 2 3
4 3 4 4 ...

output:

320

result:

ok 1 number(s): "320"

Test #46:

score: 0
Accepted
time: 151ms
memory: 22112kb

input:

100
4
4 2 3
4 3 3 1 4
1 2 3 3 1 2 4
4 3 2 3 4 3 1 1 4
2 2 3 3 1 2 4 4 1 2 3
4 3 2 1 2 3 2 1 4 4 2 1 4
1 2 1 4 1 2 3 1 1 2 2 4 4 2 3
4 3 2 4 4 3 1 4 4 3 3 1 4 3 2 1 4
1 2 4 4 1 4 3 4 1 2 4 4 1 2 3 1 1 2 3
4 3 4 4 1 3 2 1 2 4 2 1 4 4 3 1 4 1 2 1 4
1 2 2 4 1 2 3 2 1 2 3 4 4 2 3 4 1 1 1 4 1 4 2
4 3 3 1 ...

output:

1027

result:

ok 1 number(s): "1027"

Test #47:

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

input:

100
4
1 2 1
2 3 2 1 4
1 2 3 1 1 2 2
4 3 1 1 4 3 3 1 4
4 2 3 4 1 1 3 4 1 2 3
4 3 2 3 4 3 4 1 4 2 2 1 4
1 2 3 3 1 2 1 4 1 2 3 2 3 2 3
4 1 2 1 3 3 2 1 4 1 4 1 4 3 2 2 4
1 2 3 4 1 2 3 1 4 2 3 4 1 1 3 4 1 2 3
4 3 3 1 4 2 4 1 4 3 2 3 3 3 2 3 4 2 2 1 4
1 2 3 4 4 2 3 4 1 3 3 4 1 2 2 4 1 2 3 4 2 2 3
4 4 2 1 ...

output:

1147

result:

ok 1 number(s): "1147"

Test #48:

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

input:

100
4
1 2 3
4 1 2 1 1
1 2 2 4 1 2 3
4 3 2 1 2 1 2 1 3
1 2 3 3 1 2 3 4 3 2 3
4 3 4 1 3 3 2 3 4 3 1 1 4
1 2 3 4 1 2 3 4 3 2 3 4 1 2 3
4 3 3 1 4 1 2 4 4 3 2 3 4 3 1 1 4
3 2 3 4 1 4 3 4 1 2 1 4 4 2 3 4 3 2 3
4 3 2 2 4 3 1 1 2 3 2 1 4 3 2 1 1 4 3 1 4
1 2 2 4 4 2 3 2 1 2 3 4 2 3 3 2 1 2 3 4 2 2 3
4 3 2 1 ...

output:

2292

result:

ok 1 number(s): "2292"

Test #49:

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

input:

100
4
1 2 4
3 3 2 1 4
1 2 3 2 1 2 3
4 3 1 1 2 3 1 1 4
1 2 3 4 1 2 3 4 2 2 3
4 3 3 1 4 1 2 1 4 3 3 1 4
1 4 3 4 1 3 3 4 4 2 2 4 1 2 3
4 3 2 1 1 3 2 1 4 4 2 1 4 3 1 1 4
3 2 3 3 1 2 3 4 1 3 3 4 4 4 3 4 1 3 3
4 3 2 1 1 3 2 3 4 1 2 1 3 3 2 1 1 3 2 1 3
1 2 3 3 1 2 3 4 3 2 3 4 1 4 3 4 1 2 2 2 1 2 3
4 3 4 1 ...

output:

67

result:

ok 1 number(s): "67"

Test #50:

score: 0
Accepted
time: 151ms
memory: 22404kb

input:

100
4
4 2 3
4 3 1 1 4
1 2 3 2 1 2 1
4 3 2 4 3 3 2 1 4
1 3 3 4 1 2 4 4 1 1 3
4 3 2 1 4 1 2 1 4 3 4 1 4
1 2 2 4 1 3 1 4 1 1 2 4 1 2 3
2 3 2 1 1 3 2 1 3 3 2 1 4 2 2 1 4
1 2 3 4 1 3 3 4 3 2 3 3 2 2 3 3 1 2 3
4 3 3 1 2 3 4 1 4 3 2 1 4 3 4 1 4 1 2 1 4
3 3 3 4 1 2 3 4 1 4 3 4 1 3 2 1 4 2 3 1 1 2 3
4 2 2 1 ...

output:

532

result:

ok 1 number(s): "532"

Test #51:

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

input:

100
4
2 2 3
4 3 2 1 3
3 2 3 3 1 2 3
4 3 4 1 4 2 2 1 4
1 2 3 4 1 2 1 4 4 2 3
4 3 2 3 4 1 2 1 4 3 2 1 4
4 2 3 3 1 2 3 3 1 2 3 1 1 2 4
4 3 1 1 4 3 1 1 4 3 3 1 2 3 2 1 4
1 2 3 4 1 1 4 4 1 3 3 4 1 2 3 1 1 2 3
4 3 3 1 2 3 2 1 4 3 2 4 4 3 3 1 2 3 2 3 4
1 2 4 4 1 3 3 4 2 2 2 4 1 2 3 3 1 2 2 4 1 2 3
1 3 2 3 ...

output:

275

result:

ok 1 number(s): "275"

Test #52:

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

input:

100
4
4 2 3
4 3 1 1 4
1 2 3 3 1 2 2
4 2 2 1 4 3 3 1 4
1 2 3 4 2 1 3 4 1 2 3
4 2 2 1 1 3 2 1 4 2 2 1 4
1 2 2 4 1 2 2 4 1 3 3 4 4 2 3
4 3 2 1 1 3 2 1 4 1 2 1 1 3 2 1 4
3 4 3 4 4 2 3 2 2 2 3 4 3 2 3 4 2 2 3
4 1 2 1 4 3 2 1 4 3 2 2 1 2 1 1 4 3 2 3 4
1 2 3 4 3 4 3 2 1 1 4 4 1 1 3 4 1 1 4 4 1 2 3
4 3 2 2 ...

output:

54

result:

ok 1 number(s): "54"

Test #53:

score: 0
Accepted
time: 143ms
memory: 22204kb

input:

100
4
1 2 1
4 3 1 1 4
1 2 2 3 3 2 3
3 3 2 1 4 3 2 1 4
1 2 3 1 1 4 1 2 1 2 4
4 3 2 4 4 3 2 2 4 3 3 1 4
1 2 1 4 1 2 4 4 1 2 2 3 3 2 3
4 3 3 4 2 1 2 1 4 2 2 1 4 3 2 1 4
4 2 3 4 1 4 3 4 4 2 3 4 3 2 1 4 1 4 3
4 3 2 4 3 3 2 2 4 3 2 1 2 4 3 1 4 3 2 1 4
1 2 4 4 1 2 4 4 1 3 4 4 1 2 3 4 1 4 3 4 2 2 3
2 3 2 3 ...

output:

1360

result:

ok 1 number(s): "1360"

Test #54:

score: 0
Accepted
time: 139ms
memory: 22080kb

input:

100
4
3 2 3
4 3 1 1 4
1 2 3 1 1 2 4
3 2 2 1 3 3 2 1 4
1 4 3 4 1 2 3 2 1 2 4
4 3 2 1 1 3 2 2 4 3 1 1 4
1 2 3 1 1 2 2 4 1 2 1 4 1 2 3
4 3 2 4 4 3 2 1 4 4 2 1 4 4 2 1 4
1 1 3 4 2 2 3 1 1 2 3 2 1 2 3 4 1 1 3
4 3 2 1 2 3 2 1 1 3 1 1 4 2 2 1 1 3 2 1 4
1 3 3 4 4 2 3 4 3 2 3 4 1 2 1 4 1 2 3 1 1 2 1
4 3 3 1 ...

output:

2448

result:

ok 1 number(s): "2448"

Test #55:

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

input:

3
4
3 2 3
3 3 2 1 3
3 1

output:

-1

result:

ok 1 number(s): "-1"

Extra Test:

score: 0
Extra Test Passed