CF2183A.Binary Array Game

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Binary Array Game

Alice and Bob are playing a game on an array aa of size nn, containing only numbers 0 and 1. Alice moves first, with each player alternating turns.

In a player's turn, he or she chooses two integers ll and rr such that 1l<ra1 \leq l \color{red}{ \lt } r \leq |a| (here, a|a| denotes the current length of aa). Then, the subarray [al,al+1,,ar][a_l,a_{l+1},\ldots,a_r] is replaced with a single number 1min(al,al+1,,ar)1-\operatorname{min}(a_l,a_{l+1},\ldots,a_r). That is, if all numbers in the subarray are 11, then the subarray [al,al+1,,ar][a_l,a_{l+1},\ldots,a_r] is removed, and the number 00 is inserted where the subarray was. Otherwise, the subarray [al,al+1,,ar][a_l,a_{l+1},\ldots,a_r] is removed, and the number 11 is inserted where the subarray was.

The game ends when there is exactly one number left in the array (where the player to go cannot make legal moves). Alice wins if the final number is 00. Otherwise, Bob wins. Please determine who wins this game with optimal play.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1001 \le t \le 100). The description of the test cases follows.

The first line of each test case contains a positive integer nn (3n1003 \le n \le 100), denoting the length of the array aa.

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (0ai10 \le a_i \le 1).

Output

For each test case, output Alice if Alice wins, and Bob otherwise. You may output each character in any case. For example, the answers Alice, alice, ALICE, AliCe will all be interpreted the same.

Note

In the first test case, Alice can win by choosing l=2l=2 and r=3r=3. Since 1min(a2,a3)=11-\operatorname{min}(a_2,a_3)=1, the subarray [1,0][1,0] is replaced with a single integer 11, and aa becomes [1,1][1,1]. At this point, it is Bob's turn, and the only move he has is to choose l=1l=1 and r=2r=2. Since 1min(a1,a2)=01-\operatorname{min}(a_1,a_2)=0, the array aa becomes [0][0]. The game now ends, and Alice wins because the last number is 00.

In the second test case, Alice can win by choosing l=1l=1 and r=3r=3 in her first move. The array becomes [0][0], and the game ends as a win for Alice immediately.

Samples

7
3
1 1 0
3
1 1 1
3
0 1 0
4
0 0 0 0
5
1 0 1 0 1
6
0 1 0 1 0 1
6
0 1 0 1 0 0
Alice
Alice
Bob
Bob
Alice
Alice
Bob

在线编程 IDE

建议全屏模式获得最佳体验