Codeforces Round 307 (Div. 2)


A. GukiZ and Contest
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
aaa
a
b
Output
aaa
Input
pozdravstaklenidodiri
niste
dobri
Output
nisteaadddiiklooprrvz
Input
abbbaaccca
ab
aca
Output
ababacabcc
----------------------------------------------------------------------------------------------------
C. GukiZ hates Boxes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
1 1
Output
4
Input
3 2
1 0 2
Output
5
Input
4 100
3 4 5 4
Output
5
----------------------------------------------------------------------------------------------------
D. GukiZ and Binary Operations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 2 10
Output
3
Input
2 1 1 3
Output
1
Input
3 3 2 10
Output
9
----------------------------------------------------------------------------------------------------
E. GukiZ and GukiZiana
time limit per test: 10 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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