Codeforces Round 283 (Div. 1)


A. Removing Columns
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 10
codeforces
Output
0
Input
4 4
case
care
test
code
Output
2
Input
5 4
code
forc
esco
defo
rces
Output
4
----------------------------------------------------------------------------------------------------
B. Tennis Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 1 2 1
Output
2
1 3
3 1
Input
4
1 1 1 1
Output
3
1 4
2 2
4 1
Input
4
1 2 1 2
Output
0
Input
8
2 1 2 1 1 1 1 1
Output
3
1 6
2 3
6 1
----------------------------------------------------------------------------------------------------
C. Distributing Parts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3
2 4
3 5
2
1 4 2
2 5 1
Output
YES
1 1 2
Input
3
1 3
2 4
3 5
2
1 3 2
2 5 1
Output
NO
----------------------------------------------------------------------------------------------------
D. Шестерни
time limit per test: 2 секунды
memory limit per test: 256 мегабайт
input: standard input
output: standard output

Examples
Input
1 0
4
0 0
1 0
1 5
0 5
9 0
4
9 0
9 -5
10 -5
10 0
Output
YES
Input
0 0
3
1 0
2 -1
2 1
0 0
3
-1 0
-2 1
-2 -1
Output
NO
----------------------------------------------------------------------------------------------------
E. Subsequences Return
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
Output
11
Input
7 7
Output
128
----------------------------------------------------------------------------------------------------
