Codeforces Beta Round 56


A. Where Are My Flakes?
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
To the left of 2
Output
1
Input
3 2
To the right of 1
To the right of 2
Output
1
Input
3 1
To the left of 3
Output
2
Input
3 2
To the left of 2
To the right of 1
Output
-1
----------------------------------------------------------------------------------------------------
B. Serial Time!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 1
.
1 1
Output
1
Input
2 1 1
.
#
1 1
Output
1
Input
2 2 2
.#
##
..
..
1 1
Output
5
Input
3 2 2
#.
##
#.
.#
..
..
1 2
Output
7
Input
3 3 3
.#.
###
##.
.##
###
##.
...
...
...
1 1
Output
13
----------------------------------------------------------------------------------------------------
C. Mushroom Strife
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 0
Output
YES
1 
Input
2 1
1 2 1 3
Output
YES
1 3 
Input
3 2
3 2 1 2
3 1 1 10
Output
YES
5 1 2 
Input
2 1
1 2 3 7
Output
NO
----------------------------------------------------------------------------------------------------
D. Savior
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
2
Output
1
Input
2
1 2
Output
2
Input
2
3 5
Output
1
----------------------------------------------------------------------------------------------------
E. Mushroom Gnomes
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 0 657276545
1 2
Output
6
Input
2 1 1 888450282
1 2
Output
14
Input
4 5 0 10000
1 2 3 4
Output
1825
----------------------------------------------------------------------------------------------------
