Consider a two-player game with rectangles. Initially, each reactangle has rows and columns. Alternating moves, each player chooses any rectangle (that has not been fully removed yet), and removes the top row or the left column from it, thus reducing the size to either or , respectively. The player that eventually cannot make any move loses the game.
Please write a program that tells if, with perfect play, the first player can win a given game.
Input consists of several cases. Every case begins with the number of rectangles , followed by pairs of integer numbers and . Assume and .
For every case, print “wins” or
“loses”.
Input
1 1 5 1 2 2 1 5 9 1 5 4 2 1 5 5 4 2 1 6 5 4 3 1000000000 1 999999999 2 999999996 999999998
Output
wins loses loses wins loses wins loses