Codeforces Round 216 (Div. 2)


A. Valera and Plates
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 1
1 2 1
Output
1
Input
4 3 1
1 1 1 1
Output
1
Input
3 1 2
2 2 2
Output
0
Input
8 2 2
1 2 1 2 1 2 1 2
Output
4
----------------------------------------------------------------------------------------------------
B. Valera and Contest
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 1 3 13 9
Output
2 3 2 3 3 
Input
5 3 1 3 15 9
Output
3 3 3 3 3 
----------------------------------------------------------------------------------------------------
C. Valera and Elections
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 2
2 3 2
3 4 2
4 5 2
Output
1
5 
Input
5
1 2 1
2 3 2
2 4 1
4 5 1
Output
1
3 
Input
5
1 2 2
1 3 2
1 4 2
1 5 2
Output
4
5 4 3 2 
----------------------------------------------------------------------------------------------------
D. Valera and Fools
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
50 50 50
Output
7
Input
1 1
100
Output
1
Input
2 1
100 100
Output
2
Input
3 3
0 0 0
Output
1
----------------------------------------------------------------------------------------------------
E. Valera and Queries
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 3
4 5
6 7
3 1 4 7
2 4 5
1 8
Output
3
1
0
----------------------------------------------------------------------------------------------------
