Codeforces Round 315 (Div. 2)


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

Examples
Input
5 2 2
Output
2
Input
5 4 7
Output
1
Input
6 2 3
Output
1
----------------------------------------------------------------------------------------------------
B. Inventory
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3 2
Output
1 3 2 
Input
4
2 2 3 3
Output
2 1 3 4 
Input
1
2
Output
1 
----------------------------------------------------------------------------------------------------
C. Primes or Palindromes?
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
Output
40
Input
1 42
Output
1
Input
6 4
Output
172
----------------------------------------------------------------------------------------------------
D. Symmetric and Transitive
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
10
----------------------------------------------------------------------------------------------------
E. New Language
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
VC
2 1
1 V 2 C
aa
Output
ab
Input
VC
2 1
1 C 2 V
bb
Output
-1
Input
VCC
4 3
1 C 2 V
2 C 3 V
3 V 4 V
abac
Output
acaa
----------------------------------------------------------------------------------------------------
