problems / 202

Alice and Bob's Number Game

easy gcd number-theory games math 1000 ms · 256 MB

Alice and Bob's Number Game

Alice and Bob are playing a number game. Alice picks a positive integer a, and Bob picks a positive integer b. They then repeatedly apply the following operation until both numbers become equal:

  • Compute g = gcd(a, b)
  • Compute d = min(a, b) − g
  • Compute h = gcd(g, d) (where gcd(g, 0) = g)
  • Set both a and b to h

Once the numbers are equal, the game ends. Alice wins if the final number is odd; Bob wins if it's even.

Given a and b, determine who wins the game.

Input

The first line contains the number of test cases t (1 ≤ t ≤ 10^5).

Each test case contains two positive integers a and b (1 ≤ a, b ≤ 10^9).

Output

For each test case, output "Alice" if Alice wins, or "Bob" if Bob wins.

Notes

The winner is determined solely by the final number's parity after the game process converges.

Example 1

Input

3
12 8
15 6
1 1

Output

Bob
Alice
Alice

Example 2

Input

5
2 2
10 5
9 6
20 12
1000000000 1

Output

Bob
Alice
Alice
Bob
Alice

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

Hint 1

Try a small pair by hand, such as a = 4 and b = 6. Follow one operation and write down the new pair. What number do both players end up with?

Hint 2

Compare the number the game settles on with gcd(a, b). Once you can justify that the final number is gcd(a, b), the winner depends only on its parity.

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

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