This is another problem about the game of Nim, which is thoroughly explained in problem problem://problemsjutge.org:problems/upc/2004-semi1/5.pbm. But here, we may have a huge number of sets, each with a huge number of marbles.
Input consists of several cases. Every case begins with the number of sets , followed by the number of marbles of each set, all between 0 and . Assume .
For every case, tell if it is a winning or a losing configuration.
You should use a mathematical trick to solve this problem.
Input
6 1 1 0 0 5 0 1 2 0 4 0 3 3 0 5 1000 43210 17 123456 42 5 1000 43210 17 43801 42
Output
winning winning losing losing winning losing