Hide

Problem G
Splay the Spire

Languages en is

Atli is wasting his time by playing computer games, as usual. Currently he is playing the game Splay the Sire. He is currently figuring out how to defeat an enemy while only having a few cards left. The battle proceeds with Atli playing a card from his hand, then the enemy damages Atli by a fixed amount and this is then repeated. First one to lose all of their hit points loses. If both Atli and the enemy reach $0$ hit points at the same time that counts as a loss for Atli, only a clear victory will satisfy him. The problem is that each card can only be played once, when he is out of cards he will have no means to damage the enemy and thus will eventually lose. In addition to this he can not skip his turn while he still has cards in his hand. He is wondering whether the cards he has left are enough to defeat the enemy. Both Atli and the enemy have some number of initial life points and the enemy has some base damage which he inflicts on Atli each time they attack. In addition to this, both Atli and the enemy have a strength value which starts at $0$ which they add to their damage. This value can be negative but if the damage comes out negative it is rounded up to $0$. What follows is a table of all cards Atli might have.

Name

Effect

Lay into

Damage an enemy by $1$ $4$ times

Power up

Increase own strength value by $2$

Whack

Damage the enemy by $6$

Haymaker

Damage the enemy by $10$ and damage self by $3$ (Self damage is not affected by either player’s strength)

Surpass limits

Double own strength value

Dirty tactics

Lower the enemy’s strength value by $2$

Bandages

Increase own life points by $8$

Xzodiac

Win instantly if own strength value is more than twice of your own current health points

Input

The first line of the input contains three positive integers $h_ A, h_ E, d$ satisfying $1 \leq h_ A, h_ E, d \leq 10^9$. $h_ A$ is the number of life points Atli starts with, $h_ E$ is the number of life points the enemy starts with and $d$ is the enemy’s base damage. The second line of the input contains one positive integer $n$ satisfying $1 \leq n \leq 8$, the number of cards Atli has. Finally there are $n$ lines, each containing the name of a card Atli has in his hand, there will only be names from the table above.

Output

If Atli can not win, print ‘Engin vinningsleid!’. Otherwise first print the number of cards Atli will play on its own line. Then print that many lines, each with the name of one card, in the same order as Atli plays them. Do not print any cards that would be played after he has already won. If there is more than one way to win, any one of them will suffice.

Sample Input 1 Sample Output 1
10 10 1
2
Lay into
Power up
2
Power up
Lay into
Sample Input 2 Sample Output 2
8 27 3
7
Bandages
Power up
Whack
Power up
Dirty tactics
Haymaker
Power up
7
Bandages
Power up
Power up
Dirty tactics
Power up
Whack
Haymaker
Sample Input 3 Sample Output 3
7 1000000 1
6
Power up
Bandages
Power up
Whack
Surpass limits
Xzodiac
5
Power up
Power up
Whack
Surpass limits
Xzodiac
Sample Input 4 Sample Output 4
1 100 1
4
Whack
Whack
Lay into
Power up
Engin vinningsleid!

Please log in to submit a solution to this problem

Log in