QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#430230#4565. Rarest Insectsucup-team2679100 ✓17ms4140kbC++171.5kb2024-06-03 16:17:462024-06-03 16:17:47

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 1ms
memory: 4092kb

input:

6
1
1
2
2
1
2
2
2
3

output:

8
0 0
8
2
8
0 5
8
2
8
0 4
8
2
8
1 4
8
0 3
8
2
8
1 3
8
0 1
8
2
8
0 2
8
2
8
1 2
8
0 4
8
2
8
0 3
8
2
8
0 2
8
2
8
1 2
8
1 4
8
1 3
8
3 1

result:

ok 

Test #2:

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

input:

2
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
3 2

result:

ok 

Test #3:

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

input:

2
1
1

output:

8
0 0
8
2
8
0 1
8
2
8
3 1

result:

ok 

Test #4:

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

input:

3
1
2
1

output:

8
0 2
8
2
8
0 1
8
2
8
1 1
8
0 0
8
2
8
3 1

result:

ok 

Test #5:

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

input:

5
1
2
1
2
2
2
2

output:

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

result:

ok 

Test #6:

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

input:

8
1
2
1
2
2
2
1
2
2
2
3
3
3

output:

8
0 0
8
2
8
0 6
8
2
8
1 6
8
0 4
8
2
8
0 3
8
2
8
1 3
8
0 1
8
2
8
1 1
8
0 2
8
2
8
1 2
8
0 7
8
2
8
0 5
8
2
8
1 5
8
0 6
8
2
8
0 3
8
2
8
0 1
8
2
8
1 1
8
0 2
8
2
8
1 2
8
0 5
8
2
8
1 5
8
1 6
8
1 3
8
3 1

result:

ok 

Test #7:

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

input:

199
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 112
8
2
8
0 109
8
2
8
1 109
8
0 93
8
2
8
1 93
8
0 81
8
2
8
1 81
8
0 86
8
2
8
1 86
8
0 32
8
2
8
1 32
8
0 62
8
2
8
1 62
8
0 59
8
2
8
1 59
8
0 75
8
2
8
1 75
8
0 23
8
2
8
1 23
8
0 149
8
2
8
1 149
8
0 19
8
2
8
1 19
8
0 103
8
2
8
1 103
8
0 198
8
2
8
1 198
8
0 137
8
2
8
1 137
8
0 7
8
2
8
1 7
8
0 189
8
...

result:

ok 

Test #8:

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

input:

200
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

8
0 99
8
2
8
0 143
8
2
8
0 92
8
2
8
0 80
8
2
8
0 62
8
2
8
0 13
8
2
8
0 56
8
2
8
0 58
8
2
8
0 185
8
2
8
0 69
8
2
8
0 148
8
2
8
0 8
8
2
8
0 102
8
2
8
0 73
8
2
8
0 136
8
2
8
0 85
8
2
8
0 188
8
2
8
0 46
8
2
8
0 16
8
2
8
0 101
8
2
8
0 3
8
2
8
0 194
8
2
8
0 51
8
2
8
0 131
8
2
8
0 172
8
2
8
0 52
8
2
8
0 40...

result:

ok 

Test #9:

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

input:

200
1
1
1
2
1
1
1
1
1
2
2
2
2
2
1
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 99
8
2
8
0 143
8
2
8
0 92
8
2
8
0 80
8
2
8
1 80
8
0 62
8
2
8
0 13
8
2
8
0 56
8
2
8
0 58
8
2
8
0 185
8
2
8
0 69
8
2
8
1 69
8
0 148
8
2
8
1 148
8
0 8
8
2
8
1 8
8
0 102
8
2
8
1 102
8
0 73
8
2
8
1 73
8
0 136
8
2
8
0 85
8
2
8
0 188
8
2
8
0 46
8
2
8
1 46
8
0 16
8
2
8
1 16
8
0 101
8
2
8
1 101
8
0 3
8
2...

result:

ok 

Test #10:

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

input:

198
1
1
1
1
1
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 99
8
2
8
0 143
8
2
8
0 92
8
2
8
0 80
8
2
8
0 62
8
2
8
0 13
8
2
8
1 13
8
0 56
8
2
8
0 58
8
2
8
1 58
8
0 185
8
2
8
1 185
8
0 69
8
2
8
1 69
8
0 148
8
2
8
1 148
8
0 8
8
2
8
0 102
8
2
8
1 102
8
0 73
8
2
8
1 73
8
0 136
8
2
8
1 136
8
0 85
8
2
8
1 85
8
0 188
8
2
8
0 46
8
2
8
1 46
8
0 16
8
2
8
1 16
8
0 1...

result:

ok 

Test #11:

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

input:

199
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 112
8
2
8
0 109
8
2
8
1 109
8
0 93
8
2
8
1 93
8
0 81
8
2
8
1 81
8
0 86
8
2
8
1 86
8
0 32
8
2
8
1 32
8
0 62
8
2
8
1 62
8
0 59
8
2
8
1 59
8
0 75
8
2
8
1 75
8
0 23
8
2
8
1 23
8
0 149
8
2
8
1 149
8
0 19
8
2
8
1 19
8
0 103
8
2
8
1 103
8
0 198
8
2
8
1 198
8
0 137
8
2
8
1 137
8
0 7
8
2
8
1 7
8
0 189
8
...

result:

ok 

Test #12:

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

input:

197
1
1
1
2
1
2
2
2
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
2
2
2
1
2
2
2
2
1
1
1
1
2
2
1
2
1
1
2
1
2
2
2
2
2
2
2
1
1
2
1
1
1
1
2
2
2
1
2
2
2
1
1
1
2
2
2
1
1
2
1
1
1
1
1
2
2
1
1
2
2
2
1
2
2
2
1
1
1
1
1
1
2
1
2
2
1
2
2
2
1
2
2
2
1
2
1
2
2
1
2
2
1
2
1
1
2
1
1
2
1
1
2
2
2
1
1
1
1
1
1
2
1
2
2
2
...

output:

8
0 112
8
2
8
0 109
8
2
8
0 93
8
2
8
0 81
8
2
8
1 81
8
0 86
8
2
8
0 32
8
2
8
1 32
8
0 62
8
2
8
1 62
8
0 59
8
2
8
1 59
8
0 75
8
2
8
0 23
8
2
8
0 149
8
2
8
1 149
8
0 19
8
2
8
0 103
8
2
8
0 52
8
2
8
0 137
8
2
8
1 137
8
0 7
8
2
8
0 189
8
2
8
0 79
8
2
8
0 47
8
2
8
0 174
8
2
8
0 30
8
2
8
0 195
8
2
8
0 22
...

result:

ok 

Test #13:

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

input:

197
1
2
1
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 112
8
2
8
0 109
8
2
8
1 109
8
0 93
8
2
8
0 81
8
2
8
0 86
8
2
8
1 86
8
0 32
8
2
8
1 32
8
0 62
8
2
8
1 62
8
0 59
8
2
8
1 59
8
0 75
8
2
8
1 75
8
0 23
8
2
8
1 23
8
0 149
8
2
8
1 149
8
0 19
8
2
8
1 19
8
0 103
8
2
8
1 103
8
0 52
8
2
8
0 137
8
2
8
1 137
8
0 7
8
2
8
1 7
8
0 189
8
2
8
1 189
8
0 79
8
2
8
...

result:

ok 

Test #14:

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

input:

198
1
2
1
1
1
2
2
1
2
1
1
2
1
2
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 99
8
2
8
0 143
8
2
8
1 143
8
0 92
8
2
8
0 80
8
2
8
0 62
8
2
8
0 13
8
2
8
1 13
8
0 56
8
2
8
1 56
8
0 58
8
2
8
0 185
8
2
8
1 185
8
0 69
8
2
8
0 148
8
2
8
0 8
8
2
8
1 8
8
0 102
8
2
8
0 73
8
2
8
1 73
8
0 136
8
2
8
0 85
8
2
8
0 188
8
2
8
1 188
8
0 46
8
2
8
1 46
8
0 16
8
2
8
1 16
8
0 101
8
2
8
1 101
8...

result:

ok 

Test #15:

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

input:

200
1
1
2
2
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 99
8
2
8
0 143
8
2
8
0 92
8
2
8
1 92
8
0 80
8
2
8
1 80
8
0 62
8
2
8
0 13
8
2
8
1 13
8
0 56
8
2
8
1 56
8
0 58
8
2
8
1 58
8
0 185
8
2
8
1 185
8
0 69
8
2
8
1 69
8
0 148
8
2
8
1 148
8
0 8
8
2
8
0 102
8
2
8
1 102
8
0 73
8
2
8
1 73
8
0 136
8
2
8
0 85
8
2
8
1 85
8
0 188
8
2
8
1 188
8
0 46
8
2
8
1 46
8
...

result:

ok 

Test #16:

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

input:

196
1
1
1
1
1
2
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 99
8
2
8
0 143
8
2
8
0 92
8
2
8
0 80
8
2
8
0 62
8
2
8
0 13
8
2
8
1 13
8
0 56
8
2
8
0 58
8
2
8
0 185
8
2
8
0 69
8
2
8
1 69
8
0 148
8
2
8
1 148
8
0 8
8
2
8
1 8
8
0 102
8
2
8
1 102
8
0 73
8
2
8
1 73
8
0 136
8
2
8
1 136
8
0 85
8
2
8
1 85
8
0 188
8
2
8
1 188
8
0 46
8
2
8
1 46
8
0 16
8
2
8
1 16
8
0 10...

result:

ok 

Test #17:

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

input:

199
1
1
2
1
2
1
1
2
2
2
2
1
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 170
8
2
8
0 192
8
2
8
0 99
8
2
8
1 99
8
0 54
8
2
8
0 173
8
2
8
1 173
8
0 24
8
2
8
0 151
8
2
8
0 96
8
2
8
1 96
8
0 153
8
2
8
1 153
8
0 183
8
2
8
1 183
8
0 51
8
2
8
1 51
8
0 58
8
2
8
0 127
8
2
8
1 127
8
0 92
8
2
8
1 92
8
0 142
8
2
8
1 142
8
0 175
8
2
8
0 81
8
2
8
1 81
8
0 169
8
2
8
1 169
8
0 122
8...

result:

ok 

Test #18:

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

input:

196
1
1
1
1
1
1
2
2
2
2
1
2
1
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 187
8
2
8
0 120
8
2
8
0 129
8
2
8
0 4
8
2
8
0 172
8
2
8
0 2
8
2
8
0 150
8
2
8
1 150
8
0 60
8
2
8
1 60
8
0 152
8
2
8
1 152
8
0 182
8
2
8
1 182
8
0 50
8
2
8
0 117
8
2
8
1 117
8
0 126
8
2
8
0 29
8
2
8
1 29
8
0 82
8
2
8
0 174
8
2
8
1 174
8
0 168
8
2
8
1 168
8
0 159
8
2
8
1 159
8
0 171
8
2
8
0 157
8
...

result:

ok 

Test #19:

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

input:

196
1
1
1
1
1
2
1
1
2
1
2
1
1
2
2
2
2
2
2
1
1
2
1
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 187
8
2
8
0 120
8
2
8
0 129
8
2
8
0 4
8
2
8
0 172
8
2
8
0 2
8
2
8
1 2
8
0 150
8
2
8
0 60
8
2
8
0 152
8
2
8
1 152
8
0 182
8
2
8
0 50
8
2
8
1 50
8
0 117
8
2
8
0 126
8
2
8
0 29
8
2
8
1 29
8
0 82
8
2
8
1 82
8
0 174
8
2
8
1 174
8
0 168
8
2
8
1 168
8
0 159
8
2
8
1 159
8
0 171
8
2
8
1 171
8
0 157
8
2
8...

result:

ok 

Test #20:

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

input:

196
1
1
2
1
1
2
1
1
2
1
2
1
1
2
2
2
2
2
2
2
2
1
2
1
2
1
2
1
2
1
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 187
8
2
8
0 120
8
2
8
0 129
8
2
8
1 129
8
0 4
8
2
8
0 172
8
2
8
0 2
8
2
8
1 2
8
0 150
8
2
8
0 60
8
2
8
0 152
8
2
8
1 152
8
0 182
8
2
8
0 50
8
2
8
1 50
8
0 117
8
2
8
0 126
8
2
8
0 29
8
2
8
1 29
8
0 82
8
2
8
1 82
8
0 174
8
2
8
1 174
8
0 168
8
2
8
1 168
8
0 159
8
2
8
1 159
8
0 171
8
2
8
1 171
8
0 1...

result:

ok 

Test #21:

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

input:

200
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
2
2
2
2
1
1
1
1
2
1
2
1
1
2
1
1
1
2
1
2
2
1
1
2
2
1
2
2
1
2
1
2
2
1
2
1
2
2
2
2
2
2
1
2
1
1
2
2
2
2
2
1
2
2
1
1
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
...

output:

8
0 187
8
2
8
0 120
8
2
8
0 129
8
2
8
0 4
8
2
8
0 172
8
2
8
0 2
8
2
8
0 150
8
2
8
0 60
8
2
8
0 152
8
2
8
0 182
8
2
8
0 50
8
2
8
0 117
8
2
8
1 117
8
0 126
8
2
8
0 29
8
2
8
1 29
8
0 82
8
2
8
0 174
8
2
8
0 168
8
2
8
0 159
8
2
8
0 171
8
2
8
0 157
8
2
8
0 25
8
2
8
1 25
8
0 145
8
2
8
1 145
8
0 151
8
2
8
1...

result:

ok 

Test #22:

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

input:

199
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
2
2
1
1
1
2
1
1
1
1
2
2
1
2
2
1
1
1
1
2
1
1
1
1
2
2
1
2
1
1
1
1
1
2
2
2
1
2
1
2
2
1
2
2
2
1
2
1
2
2
2
1
1
1
2
1
1
2
2
2
1
2
1
1
2
2
2
2
1
1
2
1
2
1
2
2
1
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
1
2
1
2
2
1
2
1
2
2
1
2
2
2
1
...

output:

8
0 170
8
2
8
0 192
8
2
8
0 99
8
2
8
0 54
8
2
8
0 173
8
2
8
0 24
8
2
8
0 151
8
2
8
0 96
8
2
8
0 153
8
2
8
1 153
8
0 183
8
2
8
0 51
8
2
8
0 58
8
2
8
0 127
8
2
8
0 92
8
2
8
0 142
8
2
8
0 175
8
2
8
0 81
8
2
8
0 169
8
2
8
0 122
8
2
8
0 89
8
2
8
0 5
8
2
8
0 101
8
2
8
0 34
8
2
8
0 9
8
2
8
0 139
8
2
8
1 13...

result:

ok 

Test #23:

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

input:

198
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
2
1
1
2
1
1
1
1
1
2
1
1
1
1
1
2
1
2
1
1
2
2
1
2
1
1
2
1
1
1
1
1
2
1
1
2
1
1
1
2
1
1
1
1
2
2
1
2
1
2
1
1
2
2
1
1
1
2
1
1
1
1
2
1
2
2
1
2
1
1
1
1
2
1
2
1
1
2
2
1
1
1
1
1
2
2
1
1
1
2
1
2
2
2
1
1
2
1
2
2
...

output:

8
0 187
8
2
8
0 120
8
2
8
0 129
8
2
8
0 4
8
2
8
0 172
8
2
8
0 2
8
2
8
0 150
8
2
8
0 60
8
2
8
0 152
8
2
8
0 182
8
2
8
0 50
8
2
8
0 117
8
2
8
0 126
8
2
8
1 126
8
0 29
8
2
8
0 82
8
2
8
0 174
8
2
8
0 168
8
2
8
0 159
8
2
8
0 171
8
2
8
0 157
8
2
8
1 157
8
0 25
8
2
8
0 145
8
2
8
0 151
8
2
8
0 175
8
2
8
0 1...

result:

ok 

Subtask #2:

score: 15
Accepted

Test #24:

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

input:

1000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 252
8
2
8
0 443
8
2
8
1 443
8
0 344
8
2
8
1 344
8
0 861
8
2
8
1 861
8
0 743
8
2
8
1 743
8
0 791
8
2
8
1 791
8
0 493
8
2
8
1 493
8
0 205
8
2
8
1 205
8
0 467
8
2
8
1 467
8
0 182
8
2
8
1 182
8
0 317
8
2
8
1 317
8
0 605
8
2
8
1 605
8
0 642
8
2
8
1 642
8
0 29
8
2
8
1 29
8
0 982
8
2
8
1 982
8
0 489
8
...

result:

ok 

Test #25:

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

input:

1000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

8
0 252
8
2
8
0 443
8
2
8
0 344
8
2
8
0 861
8
2
8
0 743
8
2
8
0 791
8
2
8
0 493
8
2
8
0 205
8
2
8
0 467
8
2
8
0 182
8
2
8
0 317
8
2
8
0 605
8
2
8
0 642
8
2
8
0 29
8
2
8
0 982
8
2
8
0 489
8
2
8
0 726
8
2
8
0 415
8
2
8
0 171
8
2
8
0 225
8
2
8
0 310
8
2
8
0 271
8
2
8
0 847
8
2
8
0 175
8
2
8
0 760
8
2
8...

result:

ok 

Test #26:

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

input:

999
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
2
1
1
1
2
2
1
2
2
2
1
2
1
1
2
2
1
1
2
2
2
1
1
2
2
2
1
2
2
2
2
2
2
1
1
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 358
8
2
8
0 265
8
2
8
0 345
8
2
8
0 938
8
2
8
0 910
8
2
8
0 484
8
2
8
0 467
8
2
8
0 560
8
2
8
0 254
8
2
8
0 220
8
2
8
0 51
8
2
8
1 51
8
0 205
8
2
8
1 205
8
0 643
8
2
8
0 328
8
2
8
0 981
8
2
8
0 928
8
2
8
1 928
8
0 727
8
2
8
0 169
8
2
8
1 169
8
0 258
8
2
8
0 89
8
2
8
0 576
8
2
8
0 311
8
2
8
1 311...

result:

ok 

Test #27:

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

input:

999
1
1
1
1
1
1
2
2
1
1
1
1
2
2
2
1
1
2
2
1
2
1
1
1
2
1
2
2
1
2
2
2
2
1
2
2
2
2
2
1
1
2
2
1
2
2
2
1
2
2
2
2
2
1
2
1
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 358
8
2
8
0 265
8
2
8
0 345
8
2
8
0 938
8
2
8
0 910
8
2
8
0 484
8
2
8
0 467
8
2
8
1 467
8
0 560
8
2
8
1 560
8
0 254
8
2
8
0 220
8
2
8
0 51
8
2
8
0 205
8
2
8
0 643
8
2
8
1 643
8
0 328
8
2
8
1 328
8
0 981
8
2
8
1 981
8
0 928
8
2
8
0 727
8
2
8
0 169
8
2
8
1 169
8
0 258
8
2
8
1 258
8
0 89
8
2
8
0 57...

result:

ok 

Test #28:

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

input:

996
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 252
8
2
8
0 443
8
2
8
1 443
8
0 344
8
2
8
1 344
8
0 861
8
2
8
1 861
8
0 743
8
2
8
1 743
8
0 791
8
2
8
1 791
8
0 493
8
2
8
1 493
8
0 205
8
2
8
1 205
8
0 467
8
2
8
1 467
8
0 182
8
2
8
1 182
8
0 317
8
2
8
1 317
8
0 605
8
2
8
1 605
8
0 642
8
2
8
1 642
8
0 29
8
2
8
1 29
8
0 982
8
2
8
1 982
8
0 489
8
...

result:

ok 

Test #29:

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

input:

995
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
2
1
2
1
2
1
2
2
2
1
2
2
1
1
2
2
2
2
1
2
2
2
2
2
2
1
2
2
1
1
2
2
2
1
1
1
2
2
1
2
1
2
1
1
1
2
1
1
1
2
2
2
1
1
2
2
1
2
2
1
2
1
1
1
2
1
1
1
1
1
1
2
1
1
2
2
2
2
2
2
2
2
2
1
2
1
1
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
2
1
2
2
1
2
1
2
2
1
2
1
1
2
2
2
1
2
1
2
1
1
2
...

output:

8
0 358
8
2
8
0 265
8
2
8
0 345
8
2
8
0 938
8
2
8
0 910
8
2
8
0 484
8
2
8
0 467
8
2
8
0 560
8
2
8
0 254
8
2
8
0 220
8
2
8
1 220
8
0 51
8
2
8
0 205
8
2
8
0 643
8
2
8
0 328
8
2
8
0 981
8
2
8
0 928
8
2
8
0 727
8
2
8
0 169
8
2
8
1 169
8
0 258
8
2
8
1 258
8
0 89
8
2
8
0 576
8
2
8
1 576
8
0 311
8
2
8
0 34...

result:

ok 

Test #30:

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

input:

998
1
2
1
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 252
8
2
8
0 443
8
2
8
1 443
8
0 344
8
2
8
0 861
8
2
8
0 743
8
2
8
1 743
8
0 791
8
2
8
1 791
8
0 493
8
2
8
1 493
8
0 205
8
2
8
0 467
8
2
8
1 467
8
0 182
8
2
8
1 182
8
0 317
8
2
8
1 317
8
0 605
8
2
8
1 605
8
0 642
8
2
8
1 642
8
0 29
8
2
8
1 29
8
0 982
8
2
8
1 982
8
0 489
8
2
8
1 489
8
0 726
8
2
8
...

result:

ok 

Test #31:

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

input:

998
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
2
2
2
2
2
1
1
1
1
2
1
2
2
2
1
1
2
2
1
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 252
8
2
8
0 443
8
2
8
0 344
8
2
8
0 861
8
2
8
0 743
8
2
8
0 791
8
2
8
0 493
8
2
8
0 205
8
2
8
0 467
8
2
8
0 182
8
2
8
0 317
8
2
8
0 605
8
2
8
0 642
8
2
8
0 29
8
2
8
1 29
8
0 982
8
2
8
0 489
8
2
8
0 726
8
2
8
1 726
8
0 415
8
2
8
1 415
8
0 171
8
2
8
1 171
8
0 225
8
2
8
1 225
8
0 310
8
2
8
1 310
8
...

result:

ok 

Test #32:

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

input:

1000
1
2
2
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 252
8
2
8
0 443
8
2
8
1 443
8
0 344
8
2
8
1 344
8
0 861
8
2
8
0 743
8
2
8
0 791
8
2
8
0 493
8
2
8
0 205
8
2
8
1 205
8
0 467
8
2
8
1 467
8
0 182
8
2
8
1 182
8
0 317
8
2
8
1 317
8
0 605
8
2
8
1 605
8
0 642
8
2
8
1 642
8
0 29
8
2
8
1 29
8
0 982
8
2
8
1 982
8
0 489
8
2
8
1 489
8
0 726
8
2
8
1 726
8
...

result:

ok 

Test #33:

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

input:

996
1
1
1
2
1
1
2
1
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 252
8
2
8
0 443
8
2
8
0 344
8
2
8
0 861
8
2
8
1 861
8
0 743
8
2
8
0 791
8
2
8
0 493
8
2
8
1 493
8
0 205
8
2
8
0 467
8
2
8
1 467
8
0 182
8
2
8
0 317
8
2
8
0 605
8
2
8
1 605
8
0 642
8
2
8
1 642
8
0 29
8
2
8
1 29
8
0 982
8
2
8
1 982
8
0 489
8
2
8
1 489
8
0 726
8
2
8
1 726
8
0 415
8
2
8
1 415
8
0 17...

result:

ok 

Test #34:

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

input:

1000
1
2
1
1
2
1
2
2
1
1
2
2
1
2
1
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 252
8
2
8
0 443
8
2
8
1 443
8
0 344
8
2
8
0 861
8
2
8
0 743
8
2
8
1 743
8
0 791
8
2
8
0 493
8
2
8
1 493
8
0 205
8
2
8
1 205
8
0 467
8
2
8
0 182
8
2
8
0 317
8
2
8
1 317
8
0 605
8
2
8
1 605
8
0 642
8
2
8
0 29
8
2
8
1 29
8
0 982
8
2
8
0 489
8
2
8
1 489
8
0 726
8
2
8
0 415
8
2
8
1 415
8
0 171
8
2
8
...

result:

ok 

Test #35:

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

input:

1000
1
1
1
2
1
1
2
1
1
1
2
2
2
1
1
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 178
8
2
8
0 539
8
2
8
0 46
8
2
8
0 329
8
2
8
1 329
8
0 379
8
2
8
0 523
8
2
8
0 624
8
2
8
1 624
8
0 419
8
2
8
0 802
8
2
8
0 970
8
2
8
0 513
8
2
8
1 513
8
0 222
8
2
8
1 222
8
0 156
8
2
8
1 156
8
0 175
8
2
8
0 191
8
2
8
0 157
8
2
8
0 1
8
2
8
1 1
8
0 640
8
2
8
1 640
8
0 461
8
2
8
1 461
8
0 231
8
2
8...

result:

ok 

Test #36:

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

input:

997
1
1
2
1
1
1
1
1
2
1
2
1
2
2
1
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 238
8
2
8
0 81
8
2
8
0 208
8
2
8
1 208
8
0 101
8
2
8
0 914
8
2
8
0 820
8
2
8
0 625
8
2
8
0 377
8
2
8
0 803
8
2
8
1 803
8
0 971
8
2
8
0 271
8
2
8
1 271
8
0 412
8
2
8
0 157
8
2
8
1 157
8
0 270
8
2
8
1 270
8
0 644
8
2
8
0 790
8
2
8
1 790
8
0 442
8
2
8
1 442
8
0 641
8
2
8
1 641
8
0 58
8
2
8
0 219
8
...

result:

ok 

Test #37:

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

input:

995
1
1
1
2
2
1
1
2
2
2
1
1
2
2
2
1
2
2
2
2
1
1
1
2
2
1
1
1
2
2
1
2
2
1
2
1
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 238
8
2
8
0 81
8
2
8
0 208
8
2
8
0 101
8
2
8
1 101
8
0 914
8
2
8
1 914
8
0 820
8
2
8
0 625
8
2
8
0 377
8
2
8
1 377
8
0 803
8
2
8
1 803
8
0 971
8
2
8
1 971
8
0 271
8
2
8
0 412
8
2
8
0 157
8
2
8
1 157
8
0 270
8
2
8
1 270
8
0 644
8
2
8
1 644
8
0 790
8
2
8
0 442
8
2
8
1 442
8
0 641
8
2
8
1 641
8
0 5...

result:

ok 

Test #38:

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

input:

997
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
2
2
1
1
2
1
2
1
1
2
1
1
2
2
1
1
1
1
1
2
1
1
2
2
2
2
1
1
2
2
2
1
2
2
2
2
2
1
2
2
2
2
1
1
2
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
...

output:

8
0 238
8
2
8
0 81
8
2
8
0 208
8
2
8
0 101
8
2
8
0 914
8
2
8
0 820
8
2
8
0 625
8
2
8
0 377
8
2
8
0 803
8
2
8
0 971
8
2
8
1 971
8
0 271
8
2
8
0 412
8
2
8
1 412
8
0 157
8
2
8
0 270
8
2
8
0 644
8
2
8
0 790
8
2
8
0 442
8
2
8
0 641
8
2
8
1 641
8
0 58
8
2
8
1 58
8
0 219
8
2
8
0 750
8
2
8
0 683
8
2
8
1 683...

result:

ok 

Test #39:

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

input:

997
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
2
1
1
1
1
1
2
2
2
1
2
1
1
1
2
1
1
2
2
2
1
1
1
2
1
1
2
1
1
2
1
1
1
1
1
2
2
1
1
1
2
2
2
2
1
2
1
1
2
2
2
2
1
2
1
1
2
2
1
2
1
2
1
2
2
2
2
2
2
1
1
1
1
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
...

output:

8
0 238
8
2
8
0 81
8
2
8
0 208
8
2
8
0 101
8
2
8
0 914
8
2
8
0 820
8
2
8
0 625
8
2
8
0 377
8
2
8
0 803
8
2
8
0 971
8
2
8
0 271
8
2
8
0 412
8
2
8
0 157
8
2
8
0 270
8
2
8
0 644
8
2
8
0 790
8
2
8
0 442
8
2
8
0 641
8
2
8
0 58
8
2
8
0 219
8
2
8
0 750
8
2
8
0 683
8
2
8
0 264
8
2
8
0 299
8
2
8
0 173
8
2
8
...

result:

ok 

Test #40:

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

input:

996
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
2
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
2
1
2
1
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
1
2
1
1
1
1
1
1
2
1
1
2
2
2
1
1
1
1
2
2
2
2
1
2
1
1
1
1
1
2
2
1
2
2
2
1
2
1
2
1
1
2
1
1
2
2
1
1
1
2
1
1
2
2
1
2
2
2
2
1
2
1
2
1
...

output:

8
0 178
8
2
8
0 539
8
2
8
0 46
8
2
8
0 329
8
2
8
0 379
8
2
8
0 523
8
2
8
0 624
8
2
8
0 419
8
2
8
0 802
8
2
8
0 970
8
2
8
0 513
8
2
8
0 222
8
2
8
0 156
8
2
8
0 175
8
2
8
0 191
8
2
8
0 157
8
2
8
0 1
8
2
8
0 640
8
2
8
0 461
8
2
8
0 231
8
2
8
0 701
8
2
8
0 682
8
2
8
0 615
8
2
8
0 298
8
2
8
0 172
8
2
8
0...

result:

ok 

Test #41:

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

input:

995
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
2
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
2
1
1
2
1
...

output:

8
0 238
8
2
8
0 81
8
2
8
0 208
8
2
8
0 101
8
2
8
0 914
8
2
8
0 820
8
2
8
0 625
8
2
8
0 377
8
2
8
0 803
8
2
8
0 971
8
2
8
0 271
8
2
8
0 412
8
2
8
0 157
8
2
8
0 270
8
2
8
0 644
8
2
8
0 790
8
2
8
1 790
8
0 442
8
2
8
0 641
8
2
8
0 58
8
2
8
0 219
8
2
8
0 750
8
2
8
0 683
8
2
8
0 264
8
2
8
0 299
8
2
8
0 17...

result:

ok 

Test #42:

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

input:

995
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
2
2
1
1
1
2
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 238
8
2
8
0 81
8
2
8
0 208
8
2
8
0 101
8
2
8
0 914
8
2
8
0 820
8
2
8
0 625
8
2
8
0 377
8
2
8
0 803
8
2
8
0 971
8
2
8
0 271
8
2
8
0 412
8
2
8
0 157
8
2
8
0 270
8
2
8
0 644
8
2
8
0 790
8
2
8
0 442
8
2
8
0 641
8
2
8
0 58
8
2
8
0 219
8
2
8
0 750
8
2
8
1 750
8
0 683
8
2
8
0 264
8
2
8
0 299
8
2
8
0 17...

result:

ok 

Subtask #3:

score: 75
Accepted

Test #43:

score: 75
Accepted
time: 0ms
memory: 3816kb

input:

2
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
3 2

result:

ok 

Test #44:

score: 75
Accepted
time: 1ms
memory: 3860kb

input:

2
1
1

output:

8
0 0
8
2
8
0 1
8
2
8
3 1

result:

ok 

Test #45:

score: 75
Accepted
time: 1ms
memory: 3864kb

input:

3
1
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
0 2
8
2
8
1 2
8
3 1

result:

ok 

Test #46:

score: 75
Accepted
time: 1ms
memory: 3816kb

input:

6
1
2
1
2
2
2
2
3
3
3

output:

8
0 5
8
2
8
0 3
8
2
8
1 3
8
0 2
8
2
8
0 4
8
2
8
1 4
8
0 1
8
2
8
1 1
8
0 0
8
2
8
1 0
8
0 3
8
2
8
0 4
8
2
8
1 4
8
0 1
8
2
8
1 1
8
0 0
8
2
8
1 0
8
1 3
8
3 1

result:

ok 

Test #47:

score: 75
Accepted
time: 0ms
memory: 3796kb

input:

10
1
1
2
2
2
2
2
2
2
2
2
2
3
4
3
4
5
5
4
5
6

output:

8
0 5
8
2
8
0 7
8
2
8
0 2
8
2
8
1 2
8
0 8
8
2
8
1 8
8
0 6
8
2
8
1 6
8
0 0
8
2
8
1 0
8
0 1
8
2
8
1 1
8
0 9
8
2
8
1 9
8
0 4
8
2
8
1 4
8
0 3
8
2
8
1 3
8
0 2
8
2
8
0 8
8
2
8
0 6
8
2
8
0 0
8
2
8
1 0
8
0 1
8
2
8
0 0
8
2
8
0 9
8
2
8
1 9
8
0 4
8
2
8
1 4
8
0 3
8
2
8
0 9
8
2
8
0 4
8
2
8
1 4
8
1 9
8
3 4

result:

ok 

Test #48:

score: 75
Accepted
time: 12ms
memory: 4140kb

input:

2000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1708
8
2
8
0 1546
8
2
8
1 1546
8
0 46
8
2
8
1 46
8
0 329
8
2
8
1 329
8
0 379
8
2
8
1 379
8
0 523
8
2
8
1 523
8
0 624
8
2
8
1 624
8
0 419
8
2
8
1 419
8
0 1992
8
2
8
1 1992
8
0 970
8
2
8
1 970
8
0 1340
8
2
8
1 1340
8
0 222
8
2
8
1 222
8
0 1832
8
2
8
1 1832
8
0 1352
8
2
8
1 1352
8
0 191
8
2
8
1 191...

result:

ok 

Test #49:

score: 75
Accepted
time: 0ms
memory: 3872kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

8
0 1708
8
2
8
0 1546
8
2
8
0 46
8
2
8
0 329
8
2
8
0 379
8
2
8
0 523
8
2
8
0 624
8
2
8
0 419
8
2
8
0 1992
8
2
8
0 970
8
2
8
0 1340
8
2
8
0 222
8
2
8
0 1832
8
2
8
0 1352
8
2
8
0 191
8
2
8
0 1334
8
2
8
0 1217
8
2
8
0 640
8
2
8
0 1704
8
2
8
0 231
8
2
8
0 701
8
2
8
0 682
8
2
8
0 1724
8
2
8
0 1357
8
2
8
...

result:

ok 

Test #50:

score: 75
Accepted
time: 5ms
memory: 4112kb

input:

2000
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
2
1
2
2
2
1
2
2
2
1
1
2
1
1
2
1
1
2
1
1
1
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
1
1
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2...

output:

8
0 1708
8
2
8
0 1546
8
2
8
0 46
8
2
8
0 329
8
2
8
0 379
8
2
8
0 523
8
2
8
1 523
8
0 624
8
2
8
0 419
8
2
8
0 1992
8
2
8
1 1992
8
0 970
8
2
8
0 1340
8
2
8
0 222
8
2
8
0 1832
8
2
8
0 1352
8
2
8
0 191
8
2
8
0 1334
8
2
8
0 1217
8
2
8
0 640
8
2
8
0 1704
8
2
8
1 1704
8
0 231
8
2
8
0 701
8
2
8
1 701
8
0 68...

result:

ok 

Test #51:

score: 75
Accepted
time: 0ms
memory: 3884kb

input:

2000
1
1
1
2
1
1
1
1
2
1
1
1
2
1
1
2
1
1
1
1
1
1
2
2
1
2
1
1
2
1
1
2
1
2
2
1
2
2
1
2
1
1
2
2
1
2
2
2
1
2
2
1
2
2
1
2
1
2
2
2
1
1
2
2
2
1
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1708
8
2
8
0 1546
8
2
8
0 46
8
2
8
0 329
8
2
8
1 329
8
0 379
8
2
8
0 523
8
2
8
0 624
8
2
8
0 419
8
2
8
0 1992
8
2
8
1 1992
8
0 970
8
2
8
0 1340
8
2
8
0 222
8
2
8
0 1832
8
2
8
1 1832
8
0 1352
8
2
8
0 191
8
2
8
0 1334
8
2
8
1 1334
8
0 1217
8
2
8
0 640
8
2
8
0 1704
8
2
8
0 231
8
2
8
0 701
8
2
8
0 6...

result:

ok 

Test #52:

score: 75
Accepted
time: 14ms
memory: 3876kb

input:

2000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1869
8
2
8
0 758
8
2
8
1 758
8
0 1932
8
2
8
1 1932
8
0 1814
8
2
8
1 1814
8
0 592
8
2
8
1 592
8
0 630
8
2
8
1 630
8
0 586
8
2
8
1 586
8
0 1359
8
2
8
1 1359
8
0 1918
8
2
8
1 1918
8
0 1090
8
2
8
1 1090
8
0 1057
8
2
8
1 1057
8
0 900
8
2
8
1 900
8
0 1209
8
2
8
1 1209
8
0 1276
8
2
8
1 1276
8
0 1714
8
...

result:

ok 

Test #53:

score: 75
Accepted
time: 0ms
memory: 3880kb

input:

2000
1
1
2
2
2
2
2
2
2
1
2
2
2
1
2
1
2
1
1
2
1
2
2
2
1
1
1
1
1
1
1
1
2
2
1
1
1
2
2
1
1
2
1
2
2
2
2
2
2
2
2
1
2
1
1
1
1
1
2
2
2
2
1
2
1
2
2
1
1
1
2
1
2
1
2
1
2
1
2
2
2
1
1
1
2
1
2
2
1
2
1
2
2
2
2
2
1
2
2
1
1
2
2
2
2
2
1
1
1
1
2
2
1
2
2
1
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
1
2
1
2
2
1
1...

output:

8
0 1869
8
2
8
0 758
8
2
8
0 1932
8
2
8
1 1932
8
0 1814
8
2
8
1 1814
8
0 592
8
2
8
1 592
8
0 630
8
2
8
1 630
8
0 586
8
2
8
1 586
8
0 1359
8
2
8
1 1359
8
0 1918
8
2
8
1 1918
8
0 1090
8
2
8
0 1057
8
2
8
1 1057
8
0 900
8
2
8
1 900
8
0 1209
8
2
8
1 1209
8
0 1276
8
2
8
0 1714
8
2
8
1 1714
8
0 276
8
2
8
0...

result:

ok 

Test #54:

score: 75
Accepted
time: 4ms
memory: 3800kb

input:

2000
1
2
1
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1869
8
2
8
0 758
8
2
8
1 758
8
0 1932
8
2
8
0 1814
8
2
8
0 592
8
2
8
1 592
8
0 630
8
2
8
1 630
8
0 586
8
2
8
1 586
8
0 1359
8
2
8
1 1359
8
0 1918
8
2
8
0 1090
8
2
8
1 1090
8
0 1057
8
2
8
1 1057
8
0 900
8
2
8
1 900
8
0 1209
8
2
8
1 1209
8
0 1276
8
2
8
1 1276
8
0 1714
8
2
8
1 1714
8
0 276
8
2
8
1 ...

result:

ok 

Test #55:

score: 75
Accepted
time: 7ms
memory: 3872kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
2
2
2
1
1
2
1
2
2
1
1
2
2
2
1
1
2
1
2
2
2
2
2
2
1
2
1
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1869
8
2
8
0 758
8
2
8
0 1932
8
2
8
0 1814
8
2
8
0 592
8
2
8
0 630
8
2
8
0 586
8
2
8
0 1359
8
2
8
0 1918
8
2
8
0 1090
8
2
8
0 1057
8
2
8
0 900
8
2
8
0 1209
8
2
8
0 1276
8
2
8
1 1276
8
0 1714
8
2
8
1 1714
8
0 276
8
2
8
0 1161
8
2
8
0 1892
8
2
8
0 1738
8
2
8
0 1986
8
2
8
0 1
8
2
8
0 201
8
2
8
0 10...

result:

ok 

Test #56:

score: 75
Accepted
time: 0ms
memory: 4136kb

input:

1998
1
2
2
1
2
1
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1869
8
2
8
0 758
8
2
8
1 758
8
0 1932
8
2
8
1 1932
8
0 1814
8
2
8
0 592
8
2
8
1 592
8
0 630
8
2
8
0 586
8
2
8
1 586
8
0 1359
8
2
8
0 1918
8
2
8
1 1918
8
0 1090
8
2
8
0 1057
8
2
8
1 1057
8
0 900
8
2
8
1 900
8
0 1209
8
2
8
1 1209
8
0 1276
8
2
8
1 1276
8
0 1714
8
2
8
1 1714
8
0 276
8
2
8
1 276
8
0 ...

result:

ok 

Test #57:

score: 75
Accepted
time: 0ms
memory: 3820kb

input:

1999
1
1
1
2
1
1
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 843
8
2
8
0 236
8
2
8
0 1041
8
2
8
0 679
8
2
8
1 679
8
0 303
8
2
8
0 1468
8
2
8
0 1582
8
2
8
1 1582
8
0 801
8
2
8
1 801
8
0 946
8
2
8
1 946
8
0 757
8
2
8
1 757
8
0 655
8
2
8
1 655
8
0 233
8
2
8
0 1757
8
2
8
1 1757
8
0 359
8
2
8
1 359
8
0 501
8
2
8
0 521
8
2
8
1 521
8
0 883
8
2
8
1 883
8
0 1457
8...

result:

ok 

Test #58:

score: 75
Accepted
time: 6ms
memory: 4100kb

input:

1997
1
2
1
2
2
1
2
2
1
2
1
1
2
2
2
1
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 843
8
2
8
0 236
8
2
8
1 236
8
0 1041
8
2
8
0 679
8
2
8
1 679
8
0 303
8
2
8
1 303
8
0 1468
8
2
8
0 1582
8
2
8
1 1582
8
0 801
8
2
8
1 801
8
0 946
8
2
8
0 757
8
2
8
1 757
8
0 655
8
2
8
0 233
8
2
8
0 1757
8
2
8
1 1757
8
0 359
8
2
8
1 359
8
0 501
8
2
8
1 501
8
0 521
8
2
8
0 883
8
2
8
1 883
8
0 1457
8...

result:

ok 

Test #59:

score: 75
Accepted
time: 7ms
memory: 3856kb

input:

1998
1
1
1
2
1
1
1
2
1
1
2
2
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1645
8
2
8
0 499
8
2
8
0 1040
8
2
8
0 678
8
2
8
1 678
8
0 302
8
2
8
0 361
8
2
8
0 462
8
2
8
0 1469
8
2
8
1 1469
8
0 151
8
2
8
0 756
8
2
8
0 1537
8
2
8
1 1537
8
0 232
8
2
8
1 232
8
0 1756
8
2
8
0 457
8
2
8
0 500
8
2
8
1 500
8
0 605
8
2
8
1 605
8
0 882
8
2
8
1 882
8
0 1456
8
2
8
1 1456
8
0 1342
8
...

result:

ok 

Test #60:

score: 75
Accepted
time: 12ms
memory: 3820kb

input:

1996
1
1
1
1
1
1
1
1
2
1
2
1
2
1
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1645
8
2
8
0 499
8
2
8
0 1040
8
2
8
0 678
8
2
8
0 302
8
2
8
0 361
8
2
8
0 462
8
2
8
0 1469
8
2
8
0 151
8
2
8
1 151
8
0 756
8
2
8
0 1537
8
2
8
1 1537
8
0 232
8
2
8
0 1756
8
2
8
1 1756
8
0 457
8
2
8
0 500
8
2
8
1 500
8
0 605
8
2
8
1 605
8
0 882
8
2
8
0 1456
8
2
8
1 1456
8
0 1342
8
2
8
1 1342
8
0 8...

result:

ok 

Test #61:

score: 75
Accepted
time: 17ms
memory: 3848kb

input:

2000
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
2
2
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1645
8
2
8
0 499
8
2
8
0 1040
8
2
8
0 678
8
2
8
1 678
8
0 302
8
2
8
0 361
8
2
8
0 462
8
2
8
0 1469
8
2
8
0 151
8
2
8
1 151
8
0 756
8
2
8
0 1537
8
2
8
0 232
8
2
8
0 1756
8
2
8
0 457
8
2
8
0 500
8
2
8
0 605
8
2
8
0 882
8
2
8
1 882
8
0 1456
8
2
8
1 1456
8
0 1342
8
2
8
1 1342
8
0 832
8
2
8
1 832
8
0...

result:

ok 

Test #62:

score: 75
Accepted
time: 15ms
memory: 3832kb

input:

1998
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
2
2
2
1
1
1
1
1
1
1
2
2
2
1
2
2
1
1
1
2
1
2
2
2
1
1
1
2
2
1
2
2
1
2
2
2
1
1
1
2
1
2
1
2
2
1
2
1
1
1
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1645
8
2
8
0 499
8
2
8
0 1040
8
2
8
0 678
8
2
8
0 302
8
2
8
1 302
8
0 361
8
2
8
0 462
8
2
8
0 1469
8
2
8
0 151
8
2
8
0 756
8
2
8
0 1537
8
2
8
0 232
8
2
8
1 232
8
0 1756
8
2
8
0 457
8
2
8
0 500
8
2
8
0 605
8
2
8
1 605
8
0 882
8
2
8
1 882
8
0 1456
8
2
8
1 1456
8
0 1342
8
2
8
0 832
8
2
8
0 1293
8
2...

result:

ok 

Test #63:

score: 75
Accepted
time: 6ms
memory: 3824kb

input:

2000
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
2
1
2
1
2
2
1
1
1
2
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
2
2
2
1
2
1
2
1
1
1
1
1
2
2
2
1
2
1
2
1
1
2
2
2
1
1
2
2
2
2
2
2
2
2
1
2
1
1
1
1
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
1
1
1
1
2
1
1
2
1
1
2
2
2
1
1
2
2
2
1
2
2
2
1
2
1
1
1
2
2
1
2
2
2
2...

output:

8
0 236
8
2
8
0 1196
8
2
8
0 1055
8
2
8
0 576
8
2
8
0 246
8
2
8
0 396
8
2
8
0 303
8
2
8
0 1914
8
2
8
0 700
8
2
8
0 1034
8
2
8
1 1034
8
0 945
8
2
8
0 1457
8
2
8
0 1610
8
2
8
0 1448
8
2
8
0 1155
8
2
8
0 249
8
2
8
0 965
8
2
8
0 608
8
2
8
0 35
8
2
8
0 1393
8
2
8
1 1393
8
0 1219
8
2
8
0 1248
8
2
8
1 1248...

result:

ok 

Test #64:

score: 75
Accepted
time: 3ms
memory: 4100kb

input:

1995
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
2
1
1
1
2
1
1
2
2
1
1
1
2
2
2
2
2
1
1
1
1
1
1
1
2
2
1
1
2
2
1
1
1
2
1
2
2
1
2
1
1
1
2
1
2
1
1
2
1
2
1
2
2
1
1
2
2
1
2
1
1
1
2
2
1
2
2
1
1
2
2
2
1
2
2
1
2
2
1
1
2
1
1
1
2
1...

output:

8
0 237
8
2
8
0 1197
8
2
8
0 406
8
2
8
0 1176
8
2
8
0 964
8
2
8
0 1594
8
2
8
0 179
8
2
8
0 1915
8
2
8
0 1260
8
2
8
0 1692
8
2
8
0 1124
8
2
8
0 1740
8
2
8
1 1740
8
0 1611
8
2
8
0 1449
8
2
8
0 853
8
2
8
0 165
8
2
8
0 1832
8
2
8
0 609
8
2
8
0 738
8
2
8
0 1060
8
2
8
1 1060
8
0 1126
8
2
8
0 1249
8
2
8
0 ...

result:

ok 

Test #65:

score: 75
Accepted
time: 0ms
memory: 3780kb

input:

1999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
2
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1...

output:

8
0 237
8
2
8
0 1197
8
2
8
0 406
8
2
8
0 1176
8
2
8
0 964
8
2
8
0 1594
8
2
8
0 179
8
2
8
0 1915
8
2
8
0 1260
8
2
8
0 1692
8
2
8
0 1124
8
2
8
0 1740
8
2
8
0 1611
8
2
8
0 1449
8
2
8
0 853
8
2
8
0 165
8
2
8
0 1832
8
2
8
1 1832
8
0 609
8
2
8
0 738
8
2
8
0 1060
8
2
8
0 1126
8
2
8
0 1249
8
2
8
0 1395
8
2
...

result:

ok 

Test #66:

score: 75
Accepted
time: 6ms
memory: 4100kb

input:

1998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 236
8
2
8
0 1196
8
2
8
0 1055
8
2
8
0 576
8
2
8
0 246
8
2
8
0 396
8
2
8
0 303
8
2
8
0 1914
8
2
8
0 700
8
2
8
0 1034
8
2
8
0 945
8
2
8
0 1457
8
2
8
0 1610
8
2
8
0 1448
8
2
8
0 1155
8
2
8
0 249
8
2
8
0 965
8
2
8
0 608
8
2
8
0 35
8
2
8
0 1393
8
2
8
0 1219
8
2
8
0 1248
8
2
8
0 1394
8
2
8
0 1077
8
2
...

result:

ok 

Test #67:

score: 75
Accepted
time: 0ms
memory: 4132kb

input:

1999
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 237
8
2
8
0 1197
8
2
8
0 406
8
2
8
0 1176
8
2
8
0 964
8
2
8
0 1594
8
2
8
0 179
8
2
8
0 1915
8
2
8
1 1915
8
0 1260
8
2
8
0 1692
8
2
8
0 1124
8
2
8
0 1740
8
2
8
0 1611
8
2
8
0 1449
8
2
8
0 853
8
2
8
0 165
8
2
8
0 1832
8
2
8
0 609
8
2
8
0 738
8
2
8
0 1060
8
2
8
0 1126
8
2
8
0 1249
8
2
8
0 1395
8
2
...

result:

ok 

Test #68:

score: 75
Accepted
time: 7ms
memory: 3876kb

input:

1979
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
2
2
1
1
1
2
2
1
2
1
2
2
1
1
1
1
2
2
1
1
1
1
2
2
2
1
1
2
1
1
1
2
1
2
1
2
2
2
2
1
2
1
2
1
1
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2...

output:

8
0 237
8
2
8
0 1197
8
2
8
0 406
8
2
8
0 1176
8
2
8
0 964
8
2
8
0 1594
8
2
8
1 1594
8
0 179
8
2
8
0 1915
8
2
8
0 1260
8
2
8
0 1692
8
2
8
0 1124
8
2
8
0 1740
8
2
8
0 1611
8
2
8
0 1449
8
2
8
0 853
8
2
8
1 853
8
0 165
8
2
8
0 1832
8
2
8
1 1832
8
0 609
8
2
8
0 738
8
2
8
0 1060
8
2
8
0 1126
8
2
8
0 1249
...

result:

ok 

Test #69:

score: 75
Accepted
time: 3ms
memory: 3824kb

input:

1979
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
2
2
1
1
1
2
1
1
2
2
1
2
1
1
2
1
1
1
1
1
1
2
1
1
1
2
1
1
1
2
2
1
2
1
1
2
2
2
2
1
1
2
2
2
2
2
2
1
2
1
1
2
2
2
1
1
2
2
2
2
2
2
2
2
1
1
2
2
2
1
1
2
1
2
2
2
2
1
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 736
8
2
8
0 1412
8
2
8
0 1880
8
2
8
0 1241
8
2
8
0 976
8
2
8
0 1044
8
2
8
0 570
8
2
8
0 1045
8
2
8
0 1280
8
2
8
1 1280
8
0 551
8
2
8
0 1585
8
2
8
1 1585
8
0 476
8
2
8
0 992
8
2
8
0 1805
8
2
8
0 1874
8
2
8
0 334
8
2
8
1 334
8
0 326
8
2
8
0 978
8
2
8
0 1129
8
2
8
0 1418
8
2
8
1 1418
8
0 940
8
2
8
...

result:

ok 

Test #70:

score: 75
Accepted
time: 5ms
memory: 4112kb

input:

1979
1
1
1
1
1
1
2
1
1
2
2
1
1
1
1
1
2
1
1
1
2
2
2
1
2
2
2
1
2
1
2
1
2
2
1
2
1
2
1
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 736
8
2
8
0 1412
8
2
8
0 1880
8
2
8
0 1241
8
2
8
0 976
8
2
8
0 1044
8
2
8
0 570
8
2
8
1 570
8
0 1045
8
2
8
0 1280
8
2
8
0 551
8
2
8
1 551
8
0 1585
8
2
8
1 1585
8
0 476
8
2
8
0 992
8
2
8
0 1805
8
2
8
0 1874
8
2
8
0 334
8
2
8
0 326
8
2
8
1 326
8
0 978
8
2
8
0 1129
8
2
8
0 1418
8
2
8
0 940
8
2
8
1 ...

result:

ok 

Test #71:

score: 75
Accepted
time: 8ms
memory: 3868kb

input:

1979
1
1
1
1
1
1
2
1
1
2
2
1
1
1
1
1
2
1
1
1
2
2
2
1
2
2
2
1
2
1
2
1
2
2
1
2
1
2
1
2
1
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 736
8
2
8
0 1412
8
2
8
0 1880
8
2
8
0 1241
8
2
8
0 976
8
2
8
0 1044
8
2
8
0 570
8
2
8
1 570
8
0 1045
8
2
8
0 1280
8
2
8
0 551
8
2
8
1 551
8
0 1585
8
2
8
1 1585
8
0 476
8
2
8
0 992
8
2
8
0 1805
8
2
8
0 1874
8
2
8
0 334
8
2
8
0 326
8
2
8
1 326
8
0 978
8
2
8
0 1129
8
2
8
0 1418
8
2
8
0 940
8
2
8
1 ...

result:

ok 

Test #72:

score: 75
Accepted
time: 0ms
memory: 4136kb

input:

1981
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
2
2
1
1
1
2
1
1
2
2
1
2
1
1
2
1
1
1
1
1
1
2
1
1
1
2
1
1
1
2
2
1
2
1
1
2
2
2
2
1
1
2
2
2
2
2
2
1
2
1
1
2
2
2
1
1
2
2
2
2
2
2
2
2
1
1
2
2
2
1
1
2
1
2
2
2
2
1
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 736
8
2
8
0 1412
8
2
8
0 1880
8
2
8
0 1241
8
2
8
0 976
8
2
8
0 1044
8
2
8
0 570
8
2
8
0 1045
8
2
8
0 1280
8
2
8
1 1280
8
0 551
8
2
8
0 1585
8
2
8
1 1585
8
0 476
8
2
8
0 992
8
2
8
0 1805
8
2
8
0 1874
8
2
8
0 334
8
2
8
1 334
8
0 326
8
2
8
0 978
8
2
8
0 1129
8
2
8
0 1418
8
2
8
1 1418
8
0 940
8
2
8
...

result:

ok 

Test #73:

score: 75
Accepted
time: 15ms
memory: 3900kb

input:

1981
1
1
1
1
1
1
1
1
1
2
1
2
1
1
2
1
1
1
2
1
1
1
2
2
2
2
1
1
2
1
2
2
1
1
1
1
2
2
2
1
2
2
2
1
1
1
2
2
1
1
1
2
1
2
2
1
1
2
1
2
2
1
1
1
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
1
1
1
2
2
2
2
1
1
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
1
2
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 736
8
2
8
0 1412
8
2
8
0 1880
8
2
8
0 1241
8
2
8
0 976
8
2
8
0 1044
8
2
8
0 570
8
2
8
0 1045
8
2
8
0 1280
8
2
8
0 551
8
2
8
1 551
8
0 1585
8
2
8
0 476
8
2
8
1 476
8
0 992
8
2
8
0 1805
8
2
8
0 1874
8
2
8
1 1874
8
0 334
8
2
8
0 326
8
2
8
0 978
8
2
8
0 1129
8
2
8
1 1129
8
0 1418
8
2
8
0 940
8
2
8
0...

result:

ok 

Test #74:

score: 75
Accepted
time: 8ms
memory: 3868kb

input:

1989
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
2
2
2
2
1
1
1
2
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
2
1
1
2
1
2
1
1
2
2
2
1
2
2
2
2
1
1
2
2
2
2
1
2
1
2
2
2
2
1
2
2
2
2
1
1
2
2
2
2
1
2
2
1
1
2
2
2
1
2
1
2
1
2
1
2
1
2
1
2
2
2
1
2
2
2
2
2
2
2
1
1
1...

output:

8
0 736
8
2
8
0 1412
8
2
8
0 1880
8
2
8
0 1241
8
2
8
0 976
8
2
8
0 1044
8
2
8
0 570
8
2
8
0 1045
8
2
8
0 1280
8
2
8
0 551
8
2
8
0 1585
8
2
8
0 476
8
2
8
0 992
8
2
8
0 1805
8
2
8
0 1874
8
2
8
0 334
8
2
8
0 326
8
2
8
0 978
8
2
8
0 1129
8
2
8
0 1418
8
2
8
0 940
8
2
8
1 940
8
0 1100
8
2
8
0 1193
8
2
8
0...

result:

ok 

Test #75:

score: 75
Accepted
time: 3ms
memory: 3820kb

input:

1989
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
2
1
2
1
1
1
1
1
2
2
1
1
2
1
1
2
1
1
1
2
2
2
1
1
1
1
2
2
1
1
2
2
1
1
2
2
2
1
2
1
1
1
1
1
1
1
1
1
2
1
2
1
1
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
1
2
1
2
2
2
1
1
2
2
2
1
2
2
2
2
2
2
2
1
2
1
1
1
2
1
1
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
1
2
2
1
1
1
1
2
2...

output:

8
0 1123
8
2
8
0 297
8
2
8
0 491
8
2
8
0 435
8
2
8
0 699
8
2
8
0 503
8
2
8
0 854
8
2
8
0 865
8
2
8
0 1812
8
2
8
0 1964
8
2
8
0 1246
8
2
8
0 34
8
2
8
0 1567
8
2
8
0 105
8
2
8
0 1773
8
2
8
0 627
8
2
8
0 1671
8
2
8
1 1671
8
0 739
8
2
8
0 1593
8
2
8
0 1747
8
2
8
0 1072
8
2
8
0 112
8
2
8
0 1009
8
2
8
0 8...

result:

ok 

Test #76:

score: 75
Accepted
time: 0ms
memory: 3800kb

input:

1970
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
1
1
2
1
1
2
1
1
2
1
1
2
2
2
2
2
2
1
1
2
1
2
2
2
1
2
1
2
2
2
2
2
1
2
1
2
1
1
2
2
2
2
1
2
2
2
2
2
2
2
1
2
1
1
2
2
2
2
2
1
2
1
2
2
1
2
1
2
2
2
2
2
1
1
2
2
2
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1122
8
2
8
0 363
8
2
8
0 490
8
2
8
0 919
8
2
8
0 698
8
2
8
0 502
8
2
8
0 175
8
2
8
0 965
8
2
8
0 1782
8
2
8
0 207
8
2
8
0 407
8
2
8
0 101
8
2
8
0 1947
8
2
8
0 1191
8
2
8
0 1772
8
2
8
0 1683
8
2
8
0 1670
8
2
8
0 1755
8
2
8
0 1592
8
2
8
1 1592
8
0 1746
8
2
8
1 1746
8
0 528
8
2
8
1 528
8
0 10
8
2
8...

result:

ok 

Test #77:

score: 75
Accepted
time: 4ms
memory: 3828kb

input:

1970
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
2
1
2
1
1
1
2
2
1
1
1
2
1
2
2
2
1
2
1
1
1
1
2
1
2
2
1
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
1
2
1
2
2
2
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
1
2
1
2
1
2
2
1
2
2
2
1
2
2
2
1
1
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1122
8
2
8
0 363
8
2
8
0 490
8
2
8
0 919
8
2
8
0 698
8
2
8
0 502
8
2
8
0 175
8
2
8
0 965
8
2
8
0 1782
8
2
8
0 207
8
2
8
0 407
8
2
8
1 407
8
0 101
8
2
8
1 101
8
0 1947
8
2
8
0 1191
8
2
8
0 1772
8
2
8
0 1683
8
2
8
0 1670
8
2
8
0 1755
8
2
8
1 1755
8
0 1592
8
2
8
0 1746
8
2
8
1 1746
8
0 528
8
2
8
0 ...

result:

ok 

Test #78:

score: 75
Accepted
time: 12ms
memory: 3872kb

input:

1980
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
2
2
1
2
2
1
2
2
1
1
1
2
1
2
2
2
1
2
1
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
1
1
2
2
2
1
2
2
2
2
1
2
2
2
2
1...

output:

8
0 1122
8
2
8
0 363
8
2
8
0 490
8
2
8
0 919
8
2
8
0 698
8
2
8
0 502
8
2
8
0 175
8
2
8
0 965
8
2
8
0 1782
8
2
8
0 207
8
2
8
1 207
8
0 407
8
2
8
0 101
8
2
8
0 1947
8
2
8
0 1191
8
2
8
0 1772
8
2
8
0 1683
8
2
8
0 1670
8
2
8
1 1670
8
0 1755
8
2
8
0 1592
8
2
8
0 1746
8
2
8
0 528
8
2
8
0 10
8
2
8
0 1353
8...

result:

ok 

Test #79:

score: 75
Accepted
time: 7ms
memory: 4132kb

input:

1980
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
2
1
2
1
1
2
2
1
2
2
1
2
2
1
1
1
2
1
1
1
2
1
2
1
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
1
1
2
2
2
1
2
2
2
2
1
2
2
2
2
1...

output:

8
0 1122
8
2
8
0 363
8
2
8
0 490
8
2
8
0 919
8
2
8
0 698
8
2
8
0 502
8
2
8
0 175
8
2
8
0 965
8
2
8
0 1782
8
2
8
0 207
8
2
8
1 207
8
0 407
8
2
8
0 101
8
2
8
0 1947
8
2
8
0 1191
8
2
8
0 1772
8
2
8
0 1683
8
2
8
0 1670
8
2
8
1 1670
8
0 1755
8
2
8
0 1592
8
2
8
0 1746
8
2
8
0 528
8
2
8
0 10
8
2
8
0 1353
8...

result:

ok 

Test #80:

score: 75
Accepted
time: 12ms
memory: 3860kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
1
2
2
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
1
1
1
1
2
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
2
2
1
2
2
1
2
1
1
2
1
1
1
1
2
2
1
2
2
2
1
2
1
1
1
2
2
2
1
1
1
2
1
1
1
2
1
2
2
1
2
2
2
1
2
1
1
2
1
2
2
2
1
2
2
2
1
2
1
2
2
1
2
2
2
1
1...

output:

8
0 1122
8
2
8
0 363
8
2
8
0 490
8
2
8
0 919
8
2
8
0 698
8
2
8
0 502
8
2
8
0 175
8
2
8
0 965
8
2
8
0 1782
8
2
8
0 207
8
2
8
0 407
8
2
8
0 101
8
2
8
0 1947
8
2
8
0 1191
8
2
8
0 1772
8
2
8
0 1683
8
2
8
0 1670
8
2
8
0 1755
8
2
8
0 1592
8
2
8
0 1746
8
2
8
0 528
8
2
8
0 10
8
2
8
0 1353
8
2
8
0 1379
8
2
8...

result:

ok 

Test #81:

score: 75
Accepted
time: 4ms
memory: 3796kb

input:

2000
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
2
1
1
2
2
2
2
1
2
2
2
2
1
1
2
2
1
2
2
1
2
2
1
1
1
1
2
1
2
1
1
2
2
2
1
2
1
1
1
2
2
2
1
1
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
1
1
1
2
2
2
2
1
2
1
2
2
2
2
2
2
2...

output:

8
0 1094
8
2
8
0 985
8
2
8
0 1372
8
2
8
0 229
8
2
8
0 366
8
2
8
0 1532
8
2
8
0 1788
8
2
8
0 1699
8
2
8
0 1840
8
2
8
1 1840
8
0 1459
8
2
8
0 1858
8
2
8
0 825
8
2
8
0 1453
8
2
8
1 1453
8
0 1013
8
2
8
0 1681
8
2
8
0 1741
8
2
8
1 1741
8
0 1973
8
2
8
0 358
8
2
8
0 462
8
2
8
0 1201
8
2
8
0 1363
8
2
8
0 72...

result:

ok 

Test #82:

score: 75
Accepted
time: 8ms
memory: 4136kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
2
1
1
1
1
1
1
2
1
2
1
1
1
2
1
1
1
2
1
2
1
2
1
1
2
2
2
2
1
2
2
2
1
1
2
2
2
1
2
1
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
1
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1094
8
2
8
0 985
8
2
8
0 1372
8
2
8
0 229
8
2
8
0 366
8
2
8
0 1532
8
2
8
0 1788
8
2
8
0 1699
8
2
8
0 1840
8
2
8
0 1459
8
2
8
0 1858
8
2
8
0 825
8
2
8
0 1453
8
2
8
0 1013
8
2
8
0 1681
8
2
8
1 1681
8
0 1741
8
2
8
0 1973
8
2
8
0 358
8
2
8
0 462
8
2
8
0 1201
8
2
8
0 1363
8
2
8
1 1363
8
0 722
8
2
8
0...

result:

ok 

Test #83:

score: 75
Accepted
time: 5ms
memory: 3888kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
2
2
1
2
2
1
1
1
1
1
2
2
1
2
1
2
1
2
1
2
2
2
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
1
1
1
2
2
1
2
1
2
2
1
2
2
1
2
2
2
2
2
2
1
2
2
2
1
2
2
2
1
1
1
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2...

output:

8
0 1094
8
2
8
0 985
8
2
8
0 1372
8
2
8
0 229
8
2
8
0 366
8
2
8
0 1532
8
2
8
0 1788
8
2
8
0 1699
8
2
8
0 1840
8
2
8
0 1459
8
2
8
0 1858
8
2
8
0 825
8
2
8
0 1453
8
2
8
0 1013
8
2
8
0 1681
8
2
8
1 1681
8
0 1741
8
2
8
0 1973
8
2
8
0 358
8
2
8
0 462
8
2
8
0 1201
8
2
8
0 1363
8
2
8
0 722
8
2
8
0 1783
8
2...

result:

ok 

Test #84:

score: 75
Accepted
time: 5ms
memory: 3828kb

input:

540
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 385
8
2
8
0 128
8
2
8
0 419
8
2
8
1 419
8
0 229
8
2
8
1 229
8
0 366
8
2
8
1 366
8
0 521
8
2
8
1 521
8
0 232
8
2
8
1 232
8
0 172
8
2
8
1 172
8
0 24
8
2
8
1 24
8
0 41
8
2
8
1 41
8
0 236
8
2
8
1 236
8
0 252
8
2
8
1 252
8
0 537
8
2
8
1 537
8
0 135
8
2
8
1 135
8
0 442
8
2
8
1 442
8
0 267
8
2
8
1 267
...

result:

ok 

Test #85:

score: 75
Accepted
time: 9ms
memory: 4100kb

input:

1834
1
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1094
8
2
8
0 985
8
2
8
1 985
8
0 1372
8
2
8
1 1372
8
0 229
8
2
8
1 229
8
0 366
8
2
8
0 1532
8
2
8
1 1532
8
0 1788
8
2
8
1 1788
8
0 1699
8
2
8
0 621
8
2
8
1 621
8
0 1459
8
2
8
1 1459
8
0 1031
8
2
8
1 1031
8
0 825
8
2
8
1 825
8
0 1453
8
2
8
1 1453
8
0 1013
8
2
8
1 1013
8
0 1681
8
2
8
1 1681
8
0 17...

result:

ok 

Test #86:

score: 75
Accepted
time: 7ms
memory: 4096kb

input:

2000
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1094
8
2
8
0 985
8
2
8
1 985
8
0 1372
8
2
8
0 229
8
2
8
1 229
8
0 366
8
2
8
1 366
8
0 1532
8
2
8
1 1532
8
0 1788
8
2
8
1 1788
8
0 1699
8
2
8
1 1699
8
0 1840
8
2
8
1 1840
8
0 1459
8
2
8
1 1459
8
0 1858
8
2
8
1 1858
8
0 825
8
2
8
1 825
8
0 1453
8
2
8
1 1453
8
0 1013
8
2
8
1 1013
8
0 1681
8
2
8
1 1...

result:

ok 

Test #87:

score: 75
Accepted
time: 9ms
memory: 3900kb

input:

2000
1
1
1
2
2
1
1
1
1
1
1
2
1
1
1
1
1
2
2
1
1
2
1
2
2
2
1
1
2
2
1
2
1
2
2
1
2
2
2
1
2
2
2
1
2
2
2
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
1
2
1
2
2
2
1
1
2
1
2
2
2
1
1
1
1
2
1
2
1
1
2
1
1
1
1
2
2
2
1
2
2
1
1
1
2
1
2
1
2
1
2
2
2
2
1
2
2
2
2
1
2
1
2
2
2
2
1
1
1
2
1
2
2
1
2
2
2
2
2
2
1
2
1
2
1
2
2
2
1...

output:

8
0 1094
8
2
8
0 985
8
2
8
0 1372
8
2
8
0 229
8
2
8
1 229
8
0 366
8
2
8
1 366
8
0 1532
8
2
8
0 1788
8
2
8
0 1699
8
2
8
0 1840
8
2
8
0 1459
8
2
8
0 1858
8
2
8
0 825
8
2
8
1 825
8
0 1453
8
2
8
0 1013
8
2
8
0 1681
8
2
8
0 1741
8
2
8
0 1973
8
2
8
0 358
8
2
8
1 358
8
0 462
8
2
8
1 462
8
0 1201
8
2
8
0 13...

result:

ok 

Test #88:

score: 75
Accepted
time: 0ms
memory: 4112kb

input:

2000
1
1
1
1
2
2
1
2
2
2
2
2
1
2
2
1
2
2
2
1
1
1
1
2
1
1
2
2
2
2
2
2
1
2
1
2
2
2
2
1
2
1
2
2
1
1
2
1
2
1
2
2
2
2
2
1
1
2
1
1
1
1
2
2
2
1
2
1
1
2
1
1
2
2
1
1
1
1
1
2
2
2
1
1
2
1
2
1
1
2
2
1
1
2
1
1
2
1
2
1
2
2
2
1
1
2
1
2
1
1
2
1
2
2
1
2
1
1
1
1
2
2
1
1
2
2
1
2
1
1
2
1
2
2
1
1
1
1
2
2
1
1
2
1
1
1
1
1...

output:

8
0 1737
8
2
8
0 368
8
2
8
0 205
8
2
8
0 369
8
2
8
0 1783
8
2
8
1 1783
8
0 1793
8
2
8
1 1793
8
0 331
8
2
8
0 1515
8
2
8
1 1515
8
0 1873
8
2
8
1 1873
8
0 1088
8
2
8
1 1088
8
0 1397
8
2
8
1 1397
8
0 1761
8
2
8
1 1761
8
0 807
8
2
8
0 1229
8
2
8
1 1229
8
0 1090
8
2
8
1 1090
8
0 961
8
2
8
0 1345
8
2
8
1 ...

result:

ok 

Test #89:

score: 75
Accepted
time: 4ms
memory: 3804kb

input:

2000
1
2
2
2
2
2
2
2
2
1
1
2
1
1
1
1
1
2
1
2
2
2
2
1
1
1
1
2
2
1
2
2
1
1
2
1
2
2
2
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
2
2
2
1
1
2
1
2
2
2
2
2
1
2
1
1
2
1
2
1
1
2
2
1
1
1
1
1
1
1
1
1
2
1
1
1
2
2
2
2
2
1
1
1
2
2
2
1
2
1
2
2
1
1
1
2
2
1
1
2
1
2
1
1
2
1
1
2
1
2
1
1
1
1
1
2
1
1
1
1
1
2
2
2
1
1
2
1
1
1
1
1
2
1...

output:

8
0 1737
8
2
8
0 368
8
2
8
1 368
8
0 205
8
2
8
1 205
8
0 369
8
2
8
1 369
8
0 1783
8
2
8
1 1783
8
0 1793
8
2
8
1 1793
8
0 331
8
2
8
1 331
8
0 1515
8
2
8
1 1515
8
0 1873
8
2
8
1 1873
8
0 1088
8
2
8
0 1397
8
2
8
0 1761
8
2
8
1 1761
8
0 807
8
2
8
0 1229
8
2
8
0 1090
8
2
8
0 961
8
2
8
0 1345
8
2
8
0 1732...

result:

ok