Codeforces Beta Round 59 (Div. 2)


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

Examples
Input
6
Jack captain
Alice woman
Charlie man
Teddy rat
Bob child
Julia woman
Output
Teddy
Alice
Bob
Julia
Charlie
Jack
----------------------------------------------------------------------------------------------------
B. Settlers' Training
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2 2 3
Output
4
Input
4 3
1 1 1 1
Output
5
----------------------------------------------------------------------------------------------------
C. Bulls and Cows
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1263 1 2
8103 2 1
Output
Need more data
Input
2
1234 2 2
1256 0 2
Output
2134
Input
2
0123 1 1
4567 1 2
Output
Incorrect data
----------------------------------------------------------------------------------------------------
D. Dividing Island
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 2 2 3
5 8 3
Output
YES
aaabb
aabbb
cbb..
ccb..
Input
3 2 1 4 4
1 2 3 4
Output
YES
abbd
cccd
...d
...d
----------------------------------------------------------------------------------------------------
E. Sweets Game
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
  . . .
 . . O .
. . O O .
 . . . .
  . . .
Output
Lillebror
Input
  . . .
 . . . O
. . . O .
 O . O .
  . O .
Output
Karlsson
----------------------------------------------------------------------------------------------------
