Codeforces Beta Round 97 (Div. 1)


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

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

Examples
Input
0 0
10 11
10 0
0 11
1 1
2 2
2 1
1 2
Output
YES
5 6 7 8
1 2 3 4
Input
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
Output
NO
Input
0 0
4 4
4 0
0 4
1 2
2 3
3 2
2 1
Output
YES
1 2 3 4
5 6 7 8
----------------------------------------------------------------------------------------------------
C. Zero-One
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
????
Output
00
01
10
11
Input
1010
Output
10
Input
1?1
Output
01
11
----------------------------------------------------------------------------------------------------
D. Cycle
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
111
101
111
Output
8
Input
5 5
01010
10101
01010
10101
01010
Output
0
Input
7 7
1111111
1000101
1000101
1000101
1000111
1000001
1111111
Output
24
Input
5 5
11111
10001
10101
10001
11111
Output
0
----------------------------------------------------------------------------------------------------
E. Weak Subsequence
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
Output
10
Input
3 5
Output
1593
Input
2 139
Output
717248223
----------------------------------------------------------------------------------------------------
