Codeforces Round 394 (Div. 2)


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

Examples
Input
2 3
Output
YES
Input
3 1
Output
NO
----------------------------------------------------------------------------------------------------
B. Dasha and friends
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 8
2 4 6
1 5 7
Output
YES
Input
4 9
2 3 5 8
0 1 3 6
Output
YES
Input
2 4
1 3
1 2
Output
NO
----------------------------------------------------------------------------------------------------
C. Dasha and Password
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1**2
a3*0
c4**
Output
1
Input
5 5
#*&#*
*a1c&
&q2w*
#a3c#
*&#*&
Output
3
----------------------------------------------------------------------------------------------------
D. Dasha and Very Difficult Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 5
1 1 1 1 1
3 1 5 4 2
Output
3 1 5 4 2 
Input
4 2 9
3 4 8 9
3 2 1 4
Output
2 2 2 9 
Input
6 1 5
1 1 1 1 1 1
2 3 5 4 1 6
Output
-1
----------------------------------------------------------------------------------------------------
E. Dasha and Puzzle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1 2
1 3
2 4
2 5
3 6
3 7
Output
YES
0 0
1 0
0 1
2 0
1 -1
-1 1
0 2
Input
6
1 2
2 3
2 4
2 5
2 6
Output
NO
Input
4
1 2
2 3
3 4
Output
YES
3 3
4 3
5 3
6 3
----------------------------------------------------------------------------------------------------
F. Dasha and Photos
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2
aaa
aaa
aaa
1 1 2 2 b
2 2 3 3 c
Output
10
Input
5 5 3
abcde
eabcd
deabc
cdeab
bcdea
1 1 3 4 f
1 2 3 3 e
1 3 3 4 i
Output
59
----------------------------------------------------------------------------------------------------
