Codeforces Beta Round 77 (Div. 1 Only)


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

Examples
Input
3
bers
ucky
elu
PetrLoveLuckyNumbers
t
Output
PetrLovtTttttNumtttt
Input
4
hello
party
abefglghjdhfgj
IVan
petrsmatchwin
a
Output
petrsmatchwin
Input
2
aCa
cba
abAcaba
c
Output
abCacba
----------------------------------------------------------------------------------------------------
B. Lucky Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4500
Output
4747
Input
47
Output
47
----------------------------------------------------------------------------------------------------
C. Volleyball
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 3
1 2 3
1 4 1
2 4 1
2 3 5
2 7
7 2
1 2
7 7
Output
9
----------------------------------------------------------------------------------------------------
D. Horse Races
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
1 100
Output
4
Input
1 2
70 77
Output
2
Input
2 1
1 20
80 100
Output
0
0
----------------------------------------------------------------------------------------------------
E. Lucky Country
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
1 2
2 3
1 3
Output
1
Input
5 4
1 2
3 4
4 5
3 5
Output
-1
----------------------------------------------------------------------------------------------------
