Codeforces Global Round 10


A. Omkar and Password
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
2 1 3 1
2
420 420
Output
1
2
----------------------------------------------------------------------------------------------------
B. Omkar and Infinity Clock
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1
-199 192
5 19
5 -1 4 2 0
1 2
69
Output
391 0
0 6 1 3 5
0
----------------------------------------------------------------------------------------------------
C. Omkar and Waterslide
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
5 3 2 5
5
1 2 3 5 3
3
1 1 1
Output
3
2
0
----------------------------------------------------------------------------------------------------
D. Omkar and Bed Wars
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
RLRL
6
LRRRRL
8
RLLRRRLL
12
LLLLRRLRRRLL
5
RRRRR
Output
0
1
1
3
2
----------------------------------------------------------------------------------------------------
E. Omkar and Duck
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
23
26
27
Output
1 2 3 6
4 6 2 10
9 0 7 3
2 8 8 2
1 1
1 2
1 3
2 3
2 4
3 4
4 4
1 1
2 1
3 1
3 2
3 3
3 4
4 4
1 1
1 2
1 3
1 4
2 4
3 4
4 4
----------------------------------------------------------------------------------------------------
F. Omkar and Landslide
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 6 7 8
Output
5 5 6 7
----------------------------------------------------------------------------------------------------
G. Omkar and Pies
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 5
11000
00011
1 3
3 5
4 2
3 4
Output
5
1 3
Input
4 3 5
11000
00011
1 3
1 5
2 4
1 5
Output
3
1 4
----------------------------------------------------------------------------------------------------
H. ZS Shuffles Cards
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 1
Output
5
Input
3 2
Output
332748127
Input
14 9
Output
969862773
----------------------------------------------------------------------------------------------------
I. Kevin and Grid
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5 1
1 3 2 3 1
1 3 2 3 1
5
Output
-1
Input
3 3 2
1 2 2
2 1 2
3
4
Output
0
1
----------------------------------------------------------------------------------------------------
