problems / 155

Alice's Divisor Countdown

easy games math number-theory 1000 ms · 256 MB

Alice's Divisor Countdown

Alice and Bob are bored at the bus stop, so they write a positive integer n on the back of a ticket and start counting it down. They take turns, and Alice moves first. On a turn, the player picks a number d that divides the current n with 1 ≤ d < n, crosses n out and writes n − d instead. A player who has no allowed d on their turn loses (this happens exactly when the number on the ticket is 1).

Alice and Bob play a game for each of several starting numbers. Both of them play optimally. For every starting number, find out who wins.

Input

The first line contains an integer t (1 ≤ t ≤ 10^5), the number of games.

Each of the next t lines contains one integer n (1 ≤ n ≤ 10^18), the starting number of a game.

Output

For each game, print Alice if Alice wins with optimal play and Bob otherwise, one per line.

Notes

In the first example:

  • With n = 1, Alice has no move and loses immediately.
  • With n = 2, Alice subtracts 1, leaving 1 for Bob, who cannot move.
  • With n = 3, the only divisor below 3 is 1, so Alice must write 2; Bob then writes 1 and Alice is stuck.
  • With n = 4, Alice subtracts 1 and leaves Bob with 3, a losing position as shown above. (Subtracting 2 would hand Bob the winning position 2.)

Example 1

Input

4
1
2
3
4

Output

Bob
Alice
Bob
Alice

Example 2

Input

5
9
12
15
1000000000000000000
999999999999999999

Output

Bob
Alice
Bob
Alice
Bob

Hints · reveal one at a time if you're stuck

Hint 1

Work out who wins for the first few values of n by hand, and look at which of them are the positions where the player to move loses.

Hint 2

Look at the parity of the number before and after a move: what kind of divisor can an odd number have, and does an even number always have a move that hands the opponent an odd number? Prove the pattern by induction on n.

report an issue Prefer your own editor? sooks prep 155 (CLI)
Sign in to run code

Run your code on the examples, or submit it against every test.