QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#38231#840. Just CountingGuanYunchangRE 115ms13196kbC++111.6kb2022-07-04 19:54:332022-07-04 19:54:33

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 10068kb

input:

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

output:

1
1
5

result:

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

Test #2:

score: 0
Accepted
time: 115ms
memory: 10108kb

input:

500000
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #3:

score: 0
Accepted
time: 64ms
memory: 10000kb

input:

250000
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 166666 numbers

Test #5:

score: 0
Accepted
time: 49ms
memory: 11124kb

input:

166666
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3 0
3...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 166666 numbers

Test #6:

score: 0
Accepted
time: 57ms
memory: 11736kb

input:

125000
3 1
1 2
3 1
2 3
3 1
1 2
3 1
1 2
3 1
2 3
3 1
1 2
3 1
2 3
3 1
1 3
3 1
1 2
3 1
1 2
3 1
1 2
3 1
1 3
3 1
1 3
3 1
2 3
3 1
1 2
3 1
2 3
3 1
1 2
3 1
1 3
3 1
1 3
3 1
1 3
3 1
1 2
3 1
1 2
3 1
1 2
3 1
1 3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1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 45ms
memory: 11924kb

input:

83333
3 3
1 3
2 3
1 2
3 3
1 3
1 2
2 3
3 3
2 3
1 2
1 3
3 3
1 3
2 3
1 2
3 3
1 2
2 3
1 3
3 3
1 3
2 3
1 2
3 3
2 3
1 2
1 3
3 3
2 3
1 2
1 3
3 3
2 3
1 2
1 3
3 3
2 3
1 2
1 3
3 3
1 2
1 3
2 3
3 3
2 3
1 2
1 3
3 3
2 3
1 3
1 2
3 3
1 3
2 3
1 2
3 3
2 3
1 2
1 3
3 3
1 3
2 3
1 2
3 3
1 3
1 2
2 3
3 3
1 3
2 3
1 2
3 3
1 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 83333 numbers

Test #9:

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

input:

125000
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4 0
4...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 125000 numbers

Test #10:

score: 0
Accepted
time: 36ms
memory: 12068kb

input:

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

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #11:

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

input:

83333
4 2
1 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 71428 numbers

Test #13:

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

input:

62500
4 4
1 2
1 3
2 3
3 4
4 4
1 3
2 3
2 4
3 4
4 4
2 4
1 3
3 4
1 2
4 4
1 4
1 2
3 4
2 4
4 4
1 4
2 4
1 3
2 3
4 4
2 4
1 3
1 4
1 2
4 4
1 2
3 4
1 4
2 4
4 4
2 3
3 4
1 3
1 4
4 4
1 4
2 4
1 3
2 3
4 4
3 4
1 2
2 4
1 3
4 4
2 3
2 4
3 4
1 3
4 4
1 3
1 4
3 4
2 3
4 4
2 4
1 4
1 3
2 3
4 4
2 4
3 4
1 4
2 3
4 4
1 2
1 3
1 ...

output:

1
1
5
1
5
1
1
1
5
5
1
1
5
1
1
1
5
1
1
1
1
1
1
5
1
1
5
1
1
1
5
1
1
5
1
1
1
5
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
1
1
1
1
5
5
1
1
5
1
5
5
1
1
1
5
1
5
1
1
1
1
1
1
1
5
5
5
1
1
5
5
1
1
1
1
5
1
5
5
1
1
1
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
1
1
5
1
5
1
1
5
5
1
1
1
5
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
1
1
1
5
5
1
1
...

result:

ok 62500 numbers

Test #14:

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

input:

55555
4 5
1 3
2 4
2 3
1 4
3 4
4 5
2 4
3 4
1 4
2 3
1 3
4 5
1 2
3 4
1 4
2 3
1 3
4 5
2 4
1 4
1 3
2 3
3 4
4 5
3 4
1 2
1 3
2 4
2 3
4 5
1 2
1 3
3 4
1 4
2 4
4 5
1 3
1 4
2 3
3 4
2 4
4 5
1 3
1 2
3 4
2 4
1 4
4 5
1 3
2 4
3 4
1 2
2 3
4 5
1 3
3 4
1 2
2 3
1 4
4 5
1 3
1 4
3 4
1 2
2 3
4 5
1 3
2 4
1 4
2 3
1 2
4 5
3 ...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
...

result:

ok 55555 numbers

Test #15:

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

input:

50000
4 6
1 3
2 4
1 4
3 4
1 2
2 3
4 6
1 3
1 4
1 2
3 4
2 4
2 3
4 6
1 4
2 3
2 4
3 4
1 3
1 2
4 6
2 4
2 3
1 2
3 4
1 4
1 3
4 6
1 3
1 4
3 4
2 4
1 2
2 3
4 6
2 3
2 4
3 4
1 2
1 3
1 4
4 6
1 3
2 3
3 4
1 4
2 4
1 2
4 6
1 4
2 4
1 3
3 4
1 2
2 3
4 6
3 4
1 4
1 3
1 2
2 3
2 4
4 6
2 4
2 3
3 4
1 3
1 4
1 2
4 6
1 4
1 3
2 ...

output:

25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
...

result:

ok 50000 numbers

Test #16:

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

input:

100000
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5 0
5...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 37ms
memory: 10780kb

input:

83333
5 1
1 2
5 1
1 3
5 1
2 5
5 1
1 3
5 1
1 2
5 1
1 5
5 1
1 5
5 1
1 2
5 1
3 4
5 1
3 5
5 1
2 5
5 1
2 4
5 1
1 2
5 1
4 5
5 1
1 2
5 1
1 5
5 1
1 4
5 1
3 4
5 1
2 5
5 1
2 5
5 1
2 5
5 1
2 4
5 1
3 4
5 1
2 3
5 1
1 3
5 1
4 5
5 1
1 3
5 1
1 3
5 1
1 4
5 1
1 2
5 1
2 5
5 1
1 5
5 1
1 2
5 1
4 5
5 1
1 4
5 1
1 4
5 1
2 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 83333 numbers

Test #18:

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

input:

71428
5 2
2 5
2 4
5 2
2 3
1 3
5 2
3 4
1 2
5 2
1 3
1 4
5 2
1 2
2 3
5 2
3 5
3 4
5 2
2 3
2 5
5 2
1 5
2 5
5 2
1 4
2 3
5 2
1 2
4 5
5 2
1 4
1 5
5 2
1 4
3 5
5 2
3 4
1 3
5 2
3 4
1 2
5 2
1 5
1 2
5 2
2 4
2 3
5 2
3 4
3 5
5 2
2 3
2 4
5 2
2 4
1 4
5 2
2 4
1 3
5 2
1 5
3 4
5 2
1 2
2 5
5 2
1 2
1 3
5 2
4 5
1 5
5 2
2 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 71428 numbers

Test #19:

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

input:

62500
5 3
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
5
1
1
1
1
1
1
1
1
5
1
1
...

result:

ok 55555 numbers

Test #21:

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

input:

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

output:

5
1
1
1
5
1
1
1
1
5
1
5
1
1
1
1
5
1
1
1
1
5
1
1
1
5
5
1
5
1
1
5
5
1
1
5
5
5
1
5
5
1
1
5
1
5
5
5
1
1
1
1
1
1
5
1
1
1
5
5
5
1
5
1
1
1
1
1
1
5
1
1
5
5
5
5
1
1
1
5
1
1
1
1
1
1
5
5
5
1
1
1
1
5
5
1
1
5
1
5
1
1
5
1
5
5
1
1
1
5
5
5
5
5
1
5
1
1
1
1
5
5
5
5
1
1
1
1
1
5
5
1
5
5
1
1
5
5
1
5
1
1
1
5
5
5
5
1
1
1
...

result:

ok 50000 numbers

Test #22:

score: 0
Accepted
time: 44ms
memory: 12312kb

input:

45454
5 6
2 4
1 3
1 4
2 3
2 5
1 2
5 6
1 4
1 2
1 5
2 5
1 3
3 4
5 6
4 5
1 4
2 4
2 3
3 5
1 2
5 6
2 4
2 3
1 4
1 3
2 5
3 4
5 6
2 3
1 3
1 5
3 4
2 4
4 5
5 6
2 3
1 3
1 2
3 4
4 5
1 4
5 6
1 4
1 2
1 5
3 4
3 5
2 3
5 6
4 5
2 3
1 4
1 5
1 2
1 3
5 6
3 4
2 5
1 3
1 2
2 4
2 3
5 6
3 4
4 5
1 5
1 3
2 4
3 5
5 6
2 5
1 3
2 ...

output:

5
5
5
5
5
5
25
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
25
5
5
5
5
25
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
25
5
5
5
25
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
25
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
25
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
25
5
5
5
5
5
5
5
5
5
5
5
5
5
25
5
5
5
5
5
5
25
5
25
5
25
5
5
5
5
25...

result:

ok 45454 numbers

Test #23:

score: 0
Accepted
time: 44ms
memory: 12600kb

input:

41666
5 7
3 4
2 3
2 4
1 3
4 5
1 4
3 5
5 7
1 4
4 5
1 3
2 3
2 5
1 2
3 4
5 7
4 5
2 3
1 2
1 3
1 5
2 5
3 4
5 7
1 2
1 4
3 5
1 5
4 5
2 4
1 3
5 7
1 3
1 2
3 5
2 5
2 4
4 5
1 5
5 7
3 5
4 5
1 5
1 3
2 3
1 4
2 4
5 7
1 3
1 5
3 4
3 5
2 4
2 3
1 2
5 7
2 3
4 5
2 5
3 5
3 4
1 5
2 4
5 7
2 5
2 4
1 2
3 5
1 3
2 3
1 4
5 7
1 ...

output:

25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
...

result:

ok 41666 numbers

Test #24:

score: -100
Runtime Error

input:

38461
5 8
2 3
1 5
2 4
1 3
3 5
1 2
3 4
2 5
5 8
3 5
2 4
4 5
3 4
1 4
1 2
2 5
1 5
5 8
1 3
1 5
2 3
3 5
4 5
3 4
2 4
2 5
5 8
2 5
3 4
1 5
2 4
4 5
1 3
3 5
2 3
5 8
3 4
4 5
1 3
2 4
1 2
2 5
1 5
2 3
5 8
1 3
3 5
1 5
1 2
2 4
4 5
2 3
1 4
5 8
2 5
4 5
1 2
3 4
1 3
2 3
1 4
2 4
5 8
1 2
2 5
3 5
1 4
3 4
2 4
1 3
4 5
5 8
4 ...

output:

125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
125
...

result: