Codeforces Round 299 (Div. 1)


A. Tavas and Karafs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 4
1 5 3
3 3 10
7 10 2
6 4 8
Output
4
-1
8
-1
Input
1 5 2
1 5 10
2 7 4
Output
1
2
----------------------------------------------------------------------------------------------------
B. Tavas and Malekas
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2
ioi
1 3
Output
26
Input
5 2
ioi
1 2
Output
0
----------------------------------------------------------------------------------------------------
C. Tavas and Pashmaks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4 4
1 2
3 2 5 -11
1 4 2
3 4 2
3 1 5
3 2 1
Output
Cry
Input
5 4
1 2
2 2 -5 -4 6
1 2 4
2 3 5
2 4 2
4 5 2
Output
Break a heart
Input
2 1
1 2
-5 -5
1 2 10
Output
Flowers
----------------------------------------------------------------------------------------------------
E. Tavas on the Path
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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