#C8589. Optimal Game Winner

    ID: 52587 Type: Default 1000ms 256MiB

Optimal Game Winner

Optimal Game Winner

In this problem, you are given several test cases, each describing a game played by Alice and Bob. The game is played on an array of integers. For each test case:

  • You are given an integer \(N\) representing the size of the array.
  • The next line contains \(N\) space-separated integers.

Alice and Bob take turns removing one integer from the array with Alice always starting first. After every move, if the sum of the remaining integers is divisible by 3 (i.e. if \(\text{sum} \bmod 3 = 0\)), then the player who just removed a number loses the game. Both players play optimally. Your task is to determine the winner for each test case.

Input is provided via standard input and output should be written to standard output.

inputFormat

The first line of input contains an integer (T), the number of test cases. For each test case, the first line contains an integer (N) (the number of elements in the array), and the second line contains (N) space-separated integers.

outputFormat

For each test case, print a single line containing either "Alice" or "Bob" indicating the winner of the game.## sample

3
3
1 2 3
4
1 2 3 4
5
1 1 1 1 1
Bob

Alice Alice

</p>