RESN04 - STONE GAME
Alice and Bob play the following game : There are N piles of stones with Si stones in the ith pile. Piles are numbered from 1 to N. Alice and Bob play alternately, with Alice starting. In a turn, the player chooses any pile i which has at least i stones in it, and removes exactly i stones from it. The game ends when there is no such pile. The player who plays last wins the game. Assuming Alice and Bob play optimally, who will win the game?
Input
The first line contains the number of test cases T (<= 100). There follow 2T lines, 2 per test case. The first line of each test case contains N (<= 100), the number of piles. The second line contains N space separated integers, specifying the number of stones in pile 1, pile 2, ... pile N. There will be at least 1 and at most 1000 stones in any pile.
Output
Output T lines, one per test case. For each test case, output "ALICE" if Alice wins the game, and "BOB" if Bob wins the game.
Example
Input:
2
1
1
2
1 1
Output:
ALICE
ALICE
Added by: | mukulrajput |
Date: | 2009-12-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS PERL6 VB.NET |
Resource: | http://www.codechef.com |