Codeforces Round 488 by NEAR (Div. 2)


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

Examples
Input
7 3
3 5 7 1 6 2 8
1 2 7
Output
7 1 2
Input
4 4
3 4 1 0
0 1 7 9
Output
1 0
----------------------------------------------------------------------------------------------------
B. Knights of a Polygonal Table
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
4 5 9 7
1 2 11 33
Output
1 3 46 36 
Input
5 1
1 2 3 4 5
1 2 3 4 5
Output
1 3 5 7 9 
Input
1 0
2
3
Output
3 
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. 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
----------------------------------------------------------------------------------------------------
F. 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
----------------------------------------------------------------------------------------------------
