Codeforces Round 165 (Div. 1)


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

Examples
Input
2
0 3
1 5
Output
3
Input
1
0 4
Output
1
Input
2
1 10
2 2
Output
3
----------------------------------------------------------------------------------------------------
B. Greenhouse Effect
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
2 1
1 2.0
1 3.100
Output
1
Input
3 3
1 5.0
2 5.5
3 6.0
Output
0
Input
6 3
1 14.284235
2 17.921382
1 20.328172
3 20.842331
1 25.790145
1 27.204125
Output
2
----------------------------------------------------------------------------------------------------
C. Flawed Flow
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
3 2 10
1 2 10
3 1 5
Output
1
0
1
Input
4 5
1 2 10
1 3 10
2 3 5
4 2 15
3 4 5
Output
0
0
1
1
0
----------------------------------------------------------------------------------------------------
D. Maximum Waterfall
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
4 1 6
3 2 7
5 9 11
3 10 15
1 13 16
Output
4
Input
6 5
4 2 8
3 1 2
2 2 3
2 6 12
1 0 7
1 8 11
Output
2
----------------------------------------------------------------------------------------------------
E. String Theory
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
L T 1 3
L B 2 2
L B 3 3
T R 1 2
T B 2 1
T R 4 1
B R 4 3
Output
1 2 3 
3 2 1 4 
Input
3 3
L T 1 1
T R 3 1
R B 3 3
B L 1 3
L R 2 2
T B 2 2
Output
No solution
----------------------------------------------------------------------------------------------------
