Codeforces Round 263 (Div. 2)


A. Appleman and Easy Task
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
xxo
xox
oxx
Output
YES
Input
4
xxxo
xoxo
oxox
xxxx
Output
NO
----------------------------------------------------------------------------------------------------
B. Appleman and Card Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
15 10
DZFDFZDFDDDDDDF
Output
82
Input
6 4
YJSNPI
Output
4
----------------------------------------------------------------------------------------------------
C. Appleman and Toastman
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1 5
Output
26
Input
1
10
Output
10
----------------------------------------------------------------------------------------------------
D. Appleman and Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0
0 1 1
Output
2
Input
6
0 1 1 0 4
1 1 0 0 1 0
Output
1
Input
10
0 1 2 1 4 4 4 0 8
0 0 0 1 0 1 1 0 0 1
Output
27
----------------------------------------------------------------------------------------------------
E. Appleman and a Sheet of Paper
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
1 3
1 2
2 0 1
2 1 2
Output
4
3
Input
10 9
2 2 9
1 1
2 0 1
1 8
2 0 8
1 2
2 1 3
1 4
2 2 4
Output
7
2
10
4
5
----------------------------------------------------------------------------------------------------
