Codeforces Round 135 (Div. 2)


A. k-String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
aazz
Output
azaz
Input
3
abcabcabz
Output
-1
----------------------------------------------------------------------------------------------------
B. Special Offer! Super Price 999 Bourles!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1029 102
Output
999
Input
27191 17
Output
27189
----------------------------------------------------------------------------------------------------
C. Color Stripe
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
ABBACC
Output
2
ABCACA
Input
3 2
BBB
Output
1
BAB
----------------------------------------------------------------------------------------------------
D. Choosing Capital for Treeland
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1
2 3
Output
0
2 
Input
4
1 4
2 4
3 4
Output
2
1 2 3 
----------------------------------------------------------------------------------------------------
E. Parking Lot
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 11
1 15
1 123123
1 3
1 5
2 123123
2 15
1 21
2 3
1 6
1 7
1 8
Output
1
7
4
2
7
4
1
3
----------------------------------------------------------------------------------------------------
