Codeforces Round 344 (Div. 2)


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

Examples
Input
5
1 2 4 3 2
2 3 3 12 1
Output
22
Input
10
13 2 7 11 8 4 9 8 5 1
5 7 18 9 2 3 0 11 8 6
Output
46
----------------------------------------------------------------------------------------------------
B. Print Check
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 1
1 2 3
2 2
Output
2 1 3 
Input
4 2
1 2 4 3
2 3
1 2
Output
2 4 1 3 
----------------------------------------------------------------------------------------------------
D. Messenger
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 3
3-a 2-b 4-c 3-a 2-c
2-a 2-b 1-c
Output
1
Input
6 1
3-a 6-b 7-a 4-c 8-e 2-a
3-a
Output
6
Input
5 5
1-h 1-e 1-l 1-l 1-o
1-w 1-o 1-r 1-l 1-d
Output
0
----------------------------------------------------------------------------------------------------
E. Product Sum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 3 2 5
Output
39
Input
5
1 1 2 7 1
Output
49
Input
3
1 1 2
Output
9
----------------------------------------------------------------------------------------------------
