Codeforces Round 170 (Div. 2)


A. Circle Line
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 3 4 9
1 3
Output
5
Input
4
5 8 2 100
4 1
Output
15
Input
3
1 1 1
3 1
Output
1
Input
3
31 41 59
1 1
Output
0
----------------------------------------------------------------------------------------------------
B. New Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
threehorses
goodsubstrings
secret
primematrix
beautifulyear
Output
j
Input
4
aa
bdefghijklmn
opqrstuvwxyz
c
Output
ab
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. 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
----------------------------------------------------------------------------------------------------
