Codeforces Round 222 (Div. 2)


A. Playing with Dice
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4
9840 9920
9860 9980
9930 10020
10040 10090
Output
1110
1100
Input
4
9900 9850
9940 9930
10000 10020
10060 10110
Output
1100
1100
----------------------------------------------------------------------------------------------------
C. 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#..
...#
.#.#
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. 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
----------------------------------------------------------------------------------------------------
