Codeforces Round 422 (Div. 2)


A. I'm bored with life
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
Output
6
----------------------------------------------------------------------------------------------------
B. Crossword solving
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
abc
xaybz
Output
2
2 3 
Input
4 10
abcd
ebceabazcd
Output
1
2 
----------------------------------------------------------------------------------------------------
C. Hacker, pack your bags!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
1 3 4
1 2 5
5 6 1
1 2 4
Output
5
Input
3 2
4 6 3
2 4 1
3 5 4
Output
-1
----------------------------------------------------------------------------------------------------
D. My pretty girl Noora
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 4
Output
19
----------------------------------------------------------------------------------------------------
E. Liar
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
hloyaygrt
6
loyyrt
3
Output
YES
Input
9
hloyaygrt
6
loyyrt
2
Output
NO
----------------------------------------------------------------------------------------------------
F. Madness
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
2 3
Output
2
1 1 1 2 0.6666666666
1 2 2 3 0.6666666666
----------------------------------------------------------------------------------------------------
