Codeforces Round 170 (Div. 1)


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

Examples
Input
5 5
1 2
2 2 3
2 3 4
2 4 5
1 5
Output
0
Input
8 7
0
3 1 2 3
1 1
2 5 4
2 6 7
1 3
2 7 4
1 1
Output
2
Input
2 2
1 2
0
Output
1
----------------------------------------------------------------------------------------------------
B. Set of Points
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
Output
0 0
3 0
0 3
1 1
Input
6 3
Output
-1
Input
6 6
Output
10 0
-10 0
10 1
9 1
9 -1
0 -2
Input
7 4
Output
176166 6377
709276 539564
654734 174109
910147 434207
790497 366519
606663 21061
859328 886001
----------------------------------------------------------------------------------------------------
C. Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 0
Output
FIRST
1 0 1 1
Input
2 2 4
0 1 2 1
0 1 2 1
1 2 1 0
1 1 1 2
Output
SECOND
----------------------------------------------------------------------------------------------------
D. Google Code Jam
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 40
10 20 15 4 0.5
4 100 21 1 0.99
1 4 1 1 0.25
Output
24.0 18.875
Input
1 1
100000000 200000000 1 1 0
Output
100000000 1
----------------------------------------------------------------------------------------------------
E. Binary Tree on Plane
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0
1 0
2 1
Output
3.650281539872885
Input
4
0 0
1 0
2 1
2 0
Output
-1
----------------------------------------------------------------------------------------------------
