VK Cup 2016 - Qualification Round 2


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

Examples
Input
4 2
Output
2
Input
8 5
Output
3
----------------------------------------------------------------------------------------------------
B. Making Genome in Berland
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
bcd
ab
cdef
Output
abcdef
Input
4
x
y
z
w
Output
xyzw
----------------------------------------------------------------------------------------------------
C. Road Improvement
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
3 4
3 2
Output
2
2 2 1
1 3
Input
6
3 4
5 4
3 2
1 3
4 6
Output
3
1 1 
2 2 3 
2 4 5 
----------------------------------------------------------------------------------------------------
D. Three-dimensional Turtle Super Computer
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 3
000
000
111
111
Output
2
Input
3 3 3
111
111
111
111
111
111
111
111
111
Output
19
Input
1 1 10
0101010101
Output
0
----------------------------------------------------------------------------------------------------
