Codeforces Round 222 (Div. 1)


A. Maze
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 2
#..#
..#.
#...
Output
#.X#
X.#.
#...
Input
5 4 5
#...
#.#.
.#..
...#
.#.#
Output
#XXX
#X#.
X#..
...#
.#.#
----------------------------------------------------------------------------------------------------
B. Preparing for the Contest
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 9
1 3 1 2
2 1 3
4 3 6
Output
YES
2 3 2 3
Input
3 4 10
2 3 1 2
2 1 3
4 3 6
Output
YES
1 3 1 3
Input
3 4 9
2 3 1 2
2 1 3
4 3 6
Output
YES
3 3 2 3
Input
3 4 5
1 3 1 2
2 1 3
5 3 6
Output
NO
----------------------------------------------------------------------------------------------------
C. Captains Mode
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1
2
p 1
p 2
Output
1
Input
6
6 4 5 4 5 5
4
b 2
p 1
b 1
p 2
Output
0
Input
4
1 2 3 4
4
p 2
b 2
p 1
b 1
Output
-2
----------------------------------------------------------------------------------------------------
D. Developing Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 8 9
1 4 7
3 6 8
5 8 10
Output
3
1 3 4
Input
6
3 5 16
1 6 11
4 8 12
7 9 16
2 10 14
8 13 15
Output
4
1 2 3 5
----------------------------------------------------------------------------------------------------
E. Cookie Clicker
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 9
1 0
2 3
5 4
Output
6
Input
3 6
1 0
2 2
5 4
Output
5
Input
3 13
1 0
2 2
6 5
Output
7
Input
1 10000000000000000
1 0
Output
10000000000000000
----------------------------------------------------------------------------------------------------
