Codeforces Round 488 by NEAR (Div. 1)


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

Examples
Input
0 0 6 0 6 6 0 6
1 3 3 5 5 3 3 1
Output
YES
Input
0 0 6 0 6 6 0 6
7 3 9 5 11 3 9 1
Output
NO
Input
6 0 6 6 0 6 0 0
7 4 4 7 7 10 10 7
Output
YES
----------------------------------------------------------------------------------------------------
B. Open Communication
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
1 2 3 4
1 5 3 4
Output
1
Input
2 2
1 2 3 4
1 5 6 4
Output
0
Input
2 3
1 2 4 5
1 2 1 3 2 3
Output
-1
----------------------------------------------------------------------------------------------------
C. Careful Maneuvering
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 9
1 2 3
1 2 3 7 8 9 11 12 13
Output
9
Input
5 5
1 2 3 4 5
1 2 3 4 5
Output
10
----------------------------------------------------------------------------------------------------
D. Compute Power
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
8 10 9 9 8 10
1 1 1 1 1 1
Output
9000
Input
6
8 10 9 9 8 10
1 10 5 5 1 10
Output
1160
----------------------------------------------------------------------------------------------------
E. Nikita and Order Statistics
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
1 2 3 4 5
Output
6 5 4 0 0 0 
Input
2 6
-5 9
Output
1 2 0 
Input
6 99
-1 -1 -1 -1 -1 -1
Output
0 6 5 4 3 2 1 
----------------------------------------------------------------------------------------------------
F. The Moral Dilemma
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 2
and xx nand xx
and xx or xx
Output
1
Input
3 2 2
and xx. nor .xx
and xx nor xx
Output
-1
Input
4 4 5
nor x..x and ..xx and xx.. nand xx..
nand ..xx nor ..xx and xx.. nor ..xx or ..xx
Output
2
----------------------------------------------------------------------------------------------------
