Codeforces Round 484 (Div. 2)


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

Examples
Input
3
101
Output
Yes
Input
4
1011
Output
No
Input
5
10001
Output
No
----------------------------------------------------------------------------------------------------
B. Bus of Characters
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 1
0011
Output
2 1 1 2 
Input
6
10 8 9 11 13 5
010010011101
Output
6 6 2 3 3 1 4 4 1 2 5 5 
----------------------------------------------------------------------------------------------------
C. Cut 'em all!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 4
4 1
3 1
Output
1
Input
3
1 2
1 3
Output
-1
Input
10
7 1
8 4
8 10
4 7
6 5
9 3
3 5
2 10
2 5
Output
4
Input
2
1 2
Output
0
----------------------------------------------------------------------------------------------------
D. Shark
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
1 2 7 3 4 8 5 6
Output
7
Input
6
25 1 2 3 14 36
Output
2
----------------------------------------------------------------------------------------------------
E. Billiard
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 2 2 -1 1
Output
0 0
Input
4 4 2 0 1 1
Output
-1
Input
10 10 10 1 -1 0
Output
-1
----------------------------------------------------------------------------------------------------
F. The Meeting Place Cannot Be Changed
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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