Codeforces Round 534 (Div. 1)


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

Examples
Input
010
Output
1 1
1 2
1 4
----------------------------------------------------------------------------------------------------
B. Game with modulo
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
start
x
x
start
x
x
y
start
x
x
y
y
end
Output
? 0 0
? 10 1
! 1
? 0 0
? 3 4
? 2 5
! 2
? 2 4
? 2 5
? 3 10
? 9 1
! 3
----------------------------------------------------------------------------------------------------
C. Johnny Solving
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 6 2
1 2
1 3
1 4
2 3
2 4
3 4
Output
PATH
4
1 2 3 4 
Input
10 18 2
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
2 3
3 4
2 4
5 6
6 7
5 7
8 9
9 10
8 10
Output
CYCLES
4
4 1 2 3 
4
7 1 5 6 
----------------------------------------------------------------------------------------------------
D. Professional layer
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 6
30 30 30
100 4 5
Output
18
Input
1 1000000
1
100
Output
0
Input
3 5
7 7 7
1 1 1
Output
-1
----------------------------------------------------------------------------------------------------
E. Radix sum
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 6
Output
1
2
Input
4
5 7 5 7
Output
16
0
64
0
----------------------------------------------------------------------------------------------------
