Codeforces Round 108 (Div. 2)


A. Marks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
223
232
112
Output
2
Input
3 5
91728
11828
11111
Output
3
----------------------------------------------------------------------------------------------------
B. Steps
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
1 1
3
1 1
1 1
0 -2
Output
4
Input
10 10
1 2
1
-1 0
Output
0
----------------------------------------------------------------------------------------------------
C. Pocket Book
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
AAB
BAA
Output
4
Input
4 5
ABABA
BCGDG
AAAAA
YABSA
Output
216
----------------------------------------------------------------------------------------------------
D. Frames
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
#####
#.#.#
###.#
#####
Output
YES
1 1 3 3
1 1 4 5
Input
5 6
...###
...###
#####.
#...#.
#####.
Output
NO
----------------------------------------------------------------------------------------------------
E. Garden
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2
1 2 3
1 2 3
1 2 3
1 2
3 3
Output
9
.X.
.X.
.XX
Input
4 5 4
1 4 5 1 2
2 2 2 2 7
2 4 1 4 5
3 2 1 7 1
1 1
1 5
4 1
4 4
Output
26
X..XX
XXXX.
X.X..
X.XX.
----------------------------------------------------------------------------------------------------
