Codeforces Round 312 (Div. 2)


A. Lala Land and Apple Trees
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
-1 5
1 5
Output
10
Input
3
-2 2
1 4
-1 3
Output
9
Input
3
1 9
3 5
7 10
Output
9
----------------------------------------------------------------------------------------------------
B. Amr and The Large Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 2 2 1
Output
1 5
Input
5
1 2 2 3 1
Output
2 3
Input
6
1 2 2 1 1 2
Output
1 5
----------------------------------------------------------------------------------------------------
C. Amr and Chemistry
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 8 2
Output
2
Input
3
3 5 6
Output
5
----------------------------------------------------------------------------------------------------
D. Guess Your Way Out! II
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
3 4 6 0
Output
7
Input
4 3
4 10 14 1
3 6 6 0
2 3 3 1
Output
14
Input
4 2
3 4 6 1
4 12 15 1
Output
Data not sufficient!
Input
4 2
3 4 5 1
2 3 3 1
Output
Game cheated!
----------------------------------------------------------------------------------------------------
E. A Simple Task
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10 5
abacdabcda
7 10 0
5 8 1
1 4 0
3 6 0
7 10 1
Output
cbcaaaabdd
Input
10 1
agjucbvdfk
1 10 1
Output
abcdfgjkuv
----------------------------------------------------------------------------------------------------
