Codeforces Round 143 (Div. 2)


A. Team
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 0
1 1 1
1 0 0
Output
2
Input
2
1 0 0
0 1 1
Output
1
----------------------------------------------------------------------------------------------------
B. Magic, Wizardry and Wonders
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2
Output
2 1 2 
Input
5 -4 3
Output
-1
Input
5 -4 4
Output
2 4 1 4 1 
----------------------------------------------------------------------------------------------------
C. To Add or Not to Add
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2 2 2
1 1 1
1 2 3 4 5 6
Output
12
Input
0 0 10
3 2 3
1 2 3 4 5 6
Output
4
----------------------------------------------------------------------------------------------------
E. Cactus
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 11
1 2
2 3
3 4
1 4
3 5
5 6
8 6
8 7
7 6
7 9
9 10
6
1 2
3 5
6 9
9 2
9 3
9 10
Output
2
2
2
4
4
1
----------------------------------------------------------------------------------------------------
