Codeforces Round 406 (Div. 1)


A. Berzerk
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 3 2
3 1 2 3
Output
Lose Win Win Loop
Loop Win Win Win
Input
8
4 6 2 3 4
2 3 6
Output
Win Win Win Win Win Win Win
Lose Win Lose Lose Win Lose Lose
----------------------------------------------------------------------------------------------------
B. Legacy
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5 1
2 3 2 3 17
2 3 2 2 16
2 2 2 3 3
3 3 1 1 12
1 3 3 17
Output
0 28 12 
Input
4 3 1
3 4 1 3 12
2 2 3 4 10
1 2 4 16
Output
0 -1 -1 12 
----------------------------------------------------------------------------------------------------
C. Till I Collapse
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3 4 3 3
Output
4 2 1 1 1 
Input
8
1 5 7 8 1 7 6 1
Output
8 4 3 2 1 1 1 1 
----------------------------------------------------------------------------------------------------
D. Rap God
time limit per test: 7 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
4 1 t
3 2 p
1 2 s
3 2
1 3
2 1
Output
0
1
1
Input
8 4
4 6 p
3 7 o
7 8 p
4 5 d
1 3 o
4 3 p
3 2 e
8 6
3 7
8 1
4 3
Output
6
1
3
1
----------------------------------------------------------------------------------------------------
E. ALT
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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