Consider a game for two players playing alternatively. Both players show a certain number of fingers in each hand. Let X be the player that moves next, and let Y be the other player. Let and be the number of fingers shown by X, and let and be the number of fingers shown by Y. In each turn, these are the allowed moves:
Add $\bmod$ 5 as many fingers as X has in a non-empty hand (a hand showing at least one finger) to one of Y’s non-empty hands. That is:
“Move” the fingers in one of X’s hands to the other hand, provided that none of them are empty. Again, the operations are made $\bmod$ 5:
“Redistribute” the fingers in X’s hands, if one of them is empty:
Both players play perfectly. The first player to get to loses the game. A game that never ends is considered to be a draw.
Input consists of several cases, each one with , , and , all between 0 and 4. Assume and .
For every case, tell if X will win, if X will lose, or if the game is a draw.
Input
2 4 0 3 1 0 4 0 0 1 0 1 3 0 2 3 3 3 0 4 1 1 1 1
Output
WIN WIN LOSE LOSE DRAW DRAW