Codeforces Round 429 (Div. 2)


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

Examples
Input
4 2
aabb
Output
YES
Input
6 3
aacaab
Output
NO
----------------------------------------------------------------------------------------------------
B. Godsend
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 2 3
Output
First
Input
2
2 2
Output
Second
----------------------------------------------------------------------------------------------------
C. Leha and Function
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
7 3 5 3 4
2 1 3 2 3
Output
4 7 3 5 3
Input
7
4 6 5 8 8 2 6
2 1 2 2 1 1 2
Output
2 6 4 5 8 8 6
----------------------------------------------------------------------------------------------------
D. Leha and another game about graph
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 0
1
Output
-1
Input
4 5
0 0 0 -1
1 2
2 3
3 4
1 4
2 4
Output
0
Input
2 1
1 1
1 2
Output
1
1
Input
3 3
0 -1 1
1 2
2 3
1 3
Output
1
2
----------------------------------------------------------------------------------------------------
E. On the Bench
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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