There are piles of stones where the ith pile has stones in it. Alice and Bob play the following game:
Alice starts, and they alternate turns.
In a turn, a player can choose any one of the piles of stones and divide the stones in it into any number of unequal piles such that no two of the newly created piles have the same number of stones. For example, if there 8 stones in a pile, it can be divided into one of these set of piles: or .
The player who cannot make a move (because all the remaining piles are indivisible) loses the game.
Given the starting set of piles, who wins the game assuming both players play optimally (that means they will not make a move that causes them to lose the game if some better, winning move exists)?
The first line contains the number of test cases . test cases follow. The first line for each test case contains , the number of piles initially. The next line contains space delimited numbers, the number of stones in each of the piles.
Output lines, one corresponding to each test case containing ALICE if Alice wins the game and BOB otherwise.
1 3 4
For the first case, the only possible move for Alice is (4) -> (1,3). Now Bob breaks up the pile with 3 stones into (1,2). At this point Alice cannot make any move and has lost.