Codeforces Round 148 (Div. 1)


A. Not Wool Sequences
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
Output
6
----------------------------------------------------------------------------------------------------
B. Boring Partition
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2 3
Output
1
1 2 2 
Input
5 10
0 1 0 2 1
Output
3
2 2 2 2 2 
----------------------------------------------------------------------------------------------------
C. World Eater Brothers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 1
3 1
4 1
Output
1
Input
5
2 1
2 3
4 3
4 5
Output
0
----------------------------------------------------------------------------------------------------
D. Tape Programming
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
1>3>22<
1 3
4 7
7 7
1 7
Output
0 1 0 1 0 0 0 0 0 0
2 2 2 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
2 3 2 1 0 0 0 0 0 0
----------------------------------------------------------------------------------------------------
E. Meeting Her
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 8 1 7
1 2
1 3
2 4
3 4
4 6
4 5
6 7
5 7
3
2 7
1 4
5 7
Output
2
Input
4 4 1 2
1 2
1 3
2 4
3 4
1
1 4
Output
-1
----------------------------------------------------------------------------------------------------
