Codeforces Round 483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!]


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

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

Examples
Input
3 3
111
1*1
111
Output
YES
Input
2 4
*.*.
1211
Output
NO
----------------------------------------------------------------------------------------------------
C. Finite or not?
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
6 12 10
4 3 10
Output
Finite
Infinite
Input
4
1 1 2
9 36 2
4 12 3
3 5 4
Output
Finite
Finite
Finite
Infinite
----------------------------------------------------------------------------------------------------
D. XOR-pyramid
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
8 4 1
2
2 3
1 2
Output
5
12
Input
6
1 2 4 8 16 32
4
1 6
2 5
3 4
1 2
Output
60
30
12
3
----------------------------------------------------------------------------------------------------
E. Elevator
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 5
5 3
Output
10
Input
2
5 3
3 5
Output
12
----------------------------------------------------------------------------------------------------
