Bob and Alice are playing a new game. There are n boxes which have been numbered from 1 to n. Each box is either empty or contains several cards. Bob and Alice move the cards in turn. In each turn the corresponding player should choose a non-empty box A and choose another box B that B<A && (A+B)%2=1 && (A+B)%3=0. Then, take an arbitrary number (but not zero) of cards from box A to box B. The last one who can do a legal move wins. Alice is the first player. Please predict who will win the game.
Input
The first line contains an integer T (T<=100) indicating the number of test cases. The first line of each test case contains an integer n (1<=n<=10000). The second line has n integers which will not be bigger than 100. The i-th integer indicates the number of cards in the i-th box.
Output
For each test case, print the case number and the winner's name in a single line. Follow the format of the sample output.
Sample Input
2
2
1 2
7
1 3 3 2 2 1 2
Sample Output
Case 1: Alice
Case 2: Bob
分析
- 把每堆石子按照对(6)取模分成(6)种情况,那么所有的操作都会发生在(1-2,0-3,4-5)之间
- 再加以分析可以发现在很多次操作之后,编号为1,3,4的石子堆不能移动到其他堆上,并且此时其他所有堆上的石子数都可以达到0
-
- 考虑模(6)得到0,2,4的所有石子堆,在终态时他们的抑或和为(0)。在游戏进行中,如果0,2,4对应的石子堆抑或和不为(0),那么类似于NIM博弈,我们完全可以通过操作使得他们的抑或和为(0);
- 而对于0,2,4对应石子堆抑或和为(0)的状态,不管怎么操作,石子堆的抑或和都会变成非(0)数。
- 所以以上第一种状态为必胜态,第二种为必败态