Codeforces Round 669 (Div. 2)


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

Examples
Input
4
2
1 0
2
0 0
4
0 1 1 1
4
1 1 0 0
Output
1
0
1
0
2
1 1
4
1 1 0 0
----------------------------------------------------------------------------------------------------
B. Big Vova
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2
2 5
4
1 8 2 3
3
3 8 9
5
64 25 75 100 50
1
42
6
96 128 88 80 52 7
5
2 4 8 16 17
Output
5 2 
8 2 1 3 
9 3 8 
100 50 25 75 64 
42 
128 96 80 88 52 7 
17 2 4 8 16 
----------------------------------------------------------------------------------------------------
C. Chocolate Bunny
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
1
0
Output
? 1 2
? 3 2
? 1 3
? 2 1
! 1 3 2
----------------------------------------------------------------------------------------------------
D. Discrete Centrifugal Jumps
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3 1 4 5
Output
3
Input
4
4 2 2 4
Output
1
Input
2
1 1
Output
1
Input
5
100 1 100 1 100
Output
2
----------------------------------------------------------------------------------------------------
E. Egor in the Republic of Dagestan
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1 2 0
1 3 1
2 3 0
2 3 1
Output
2
011
Input
4 8
1 1 0
1 3 0
1 3 1
3 2 0
2 1 0
3 4 1
2 4 0
2 4 1
Output
3
1101
Input
5 10
1 2 0
1 3 1
1 4 0
2 3 0
2 3 1
2 5 0
3 4 0
3 4 1
4 2 1
4 5 0
Output
-1
11111
----------------------------------------------------------------------------------------------------
