Codeforces Round 420 (Div. 2)


A. Okabe and Future Gadget Laboratory
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 2
2 3 1
6 4 1
Output
Yes
Input
3
1 5 2
1 1 1
1 2 3
Output
No
----------------------------------------------------------------------------------------------------
B. Okabe and Banana Trees
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 5
Output
30
Input
2 3
Output
25
----------------------------------------------------------------------------------------------------
C. Okabe and Boxes
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
add 1
remove
add 2
add 3
remove
remove
Output
1
Input
7
add 3
add 2
add 1
remove
add 4
remove
remove
remove
add 6
add 7
add 5
remove
remove
remove
Output
2
----------------------------------------------------------------------------------------------------
D. Okabe and City
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4 5
1 1
2 1
2 3
3 3
4 3
Output
2
Input
5 5 4
1 1
2 1
3 1
3 2
Output
-1
Input
2 2 4
1 1
1 2
2 1
2 2
Output
0
Input
5 5 4
1 1
2 2
3 3
4 4
Output
3
----------------------------------------------------------------------------------------------------
E. Okabe and El Psy Kongroo
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 3
0 3 3
Output
4
Input
2 6
0 3 0
3 10 2
Output
4
----------------------------------------------------------------------------------------------------
