Codeforces Round 240 (Div. 1)


A. Mashmokh and Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
Output
1 2 3 4 5
Input
5 3
Output
2 4 3 7 1
Input
7 2
Output
-1
----------------------------------------------------------------------------------------------------
B. Mashmokh and ACM
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
Output
5
Input
6 4
Output
39
Input
2 1
Output
2
----------------------------------------------------------------------------------------------------
C. Mashmokh and Reverse Operation
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1 4 3
4
1 2 0 2
Output
0
6
6
0
Input
1
1 2
3
0 1 1
Output
0
1
0
----------------------------------------------------------------------------------------------------
D. Mashmokh and Water Tanks
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10 2 1
1 2
1 3
3 4
3 5
2 6
6 8
6 7
9 8
8 10
Output
2
Input
5 1000 1000
1 2
1 3
3 4
3 5
Output
4
----------------------------------------------------------------------------------------------------
E. Mashmokh's Designed Problem
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 9
1 2
1 3
1 4
0
1 1 4
2 4 2
1 3 4
3 1
3 2
2 3 2
1 1 2
3 1
3 2
Output
3
2
2
4
1
3
4
Input
2 2
1 2
0
1 2 1
3 1
Output
1
2
----------------------------------------------------------------------------------------------------
