Codeforces Round 206 (Div. 2)


A. Vasya and Digital Root
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
Output
5881
Input
5 1
Output
36172
Input
1 0
Output
0
----------------------------------------------------------------------------------------------------
B. Vasya and Public Transport
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 3 7 19
2 3
2 5
4 4 4
Output
12
Input
4 3 2 1
1 3
798
1 2 3
Output
1
Input
100 100 8 100
3 5
7 94 12
100 1 47 0 42
Output
16
----------------------------------------------------------------------------------------------------
C. Vasya and Robot
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 4 19 1
42 3 99
Output
576
Input
4 7 2 3 9
1 2 3 4
Output
34
----------------------------------------------------------------------------------------------------
D. Game with Strings
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
ab
cd
Output
DRAW
Input
2
xa
ay
Output
FIRST
Input
3
aab
bcb
bac
Output
DRAW
----------------------------------------------------------------------------------------------------
E. Vasya and Beautiful Arrays
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 1
3 6 10 12 13 16
Output
3
Input
5 3
8 21 52 15 77
Output
7
----------------------------------------------------------------------------------------------------
