Codeforces Beta Round 80 (Div. 1 Only)


A. Testing Pants for Sadness
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1
Output
2
Input
2
2 2
Output
5
Input
1
10
Output
10
----------------------------------------------------------------------------------------------------
B. Cthulhu
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 6
6 3
6 4
5 1
2 5
1 4
5 4
Output
FHTAGN!
Input
6 5
5 6
4 6
3 1
5 1
1 2
Output
NO
----------------------------------------------------------------------------------------------------
C. Russian Roulette
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 3
1
2
3
Output
..X
Input
6 3 6
1
2
3
4
5
6
Output
.X.X.X
Input
5 2 5
1
2
3
4
5
Output
...XX
----------------------------------------------------------------------------------------------------
D. Time to Raid Cowavans
time limit per test: 4 seconds
memory limit per test: 70 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
2
1 1
1 2
Output
6
4
Input
4
2 3 5 7
3
1 3
2 3
2 2
Output
9
3
10
----------------------------------------------------------------------------------------------------
E. Buying Sets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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