Codeforces Round 217 (Div. 2)


A. Rook, Bishop and King
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 1 6
Output
2 1 3
Input
5 5 5 6
Output
1 0 1
----------------------------------------------------------------------------------------------------
B. Berland Bingo
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1
3 2 4 1
2 10 11
Output
YES
NO
YES
Input
2
1 1
1 1
Output
NO
NO
----------------------------------------------------------------------------------------------------
C. Mittens
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
1 3 2 2 1 1
Output
6
2 1
1 2
2 1
1 3
1 2
3 1
Input
4 2
1 2 1 1
Output
2
1 2
1 1
2 1
1 1
----------------------------------------------------------------------------------------------------
D. Broken Monitor
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 8
..w..w..
........
........
..w..w..
Output
..w++w..
..+..+..
..+..+..
..w++w..
Input
5 6
......
.w....
......
..w...
......
Output
......
+w+...
+.+...
++w...
......
Input
2 4
....
.w..
Output
....
.w..
Input
2 6
w..w.w
...w..
Output
-1
----------------------------------------------------------------------------------------------------
E. Summer Reading
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
0 1 0 0 0 3 0
Output
3
1 1 2 2 3 3 3 
Input
8
0 0 0 0 0 0 0 0
Output
4
1 1 2 2 3 3 4 4 
Input
4
0 0 1 0
Output
1
1 1 1 1 
Input
4
0 0 0 3
Output
-1
----------------------------------------------------------------------------------------------------
