Codeforces Beta Round 15


A. Cottage Village
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
----------------------------------------------------------------------------------------------------
B. Laser
time limit per test: 1 second
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
2
4 4 1 1 3 3
4 3 1 1 2 2
Output
8
2
----------------------------------------------------------------------------------------------------
C. Industrial Nim
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1
3 2
Output
tolik
Input
4
1 1
1 1
1 1
1 1
Output
bolik
----------------------------------------------------------------------------------------------------
D. Map
time limit per test: 2 seconds
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
2 2 1 2
1 2
3 5
Output
2
1 1 1
2 1 2
Input
4 4 2 2
1 5 3 4
2 7 6 1
1 1 2 2
2 2 1 2
Output
3
3 1 2
3 3 3
1 2 9
----------------------------------------------------------------------------------------------------
E. Triangles
time limit per test: 1 second
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
10
Input
4
Output
74
----------------------------------------------------------------------------------------------------
