Sum Game
Limits: 2 sec., 512 MiB
Ana and Bob play the following game.
First, Bob chooses a sequence of \(n\) positive integers \(a_1, a_2, \dots, a_n\). Then Ana is allowed to perform the following operations.
She may erase any of the numbers from the sequence, but she is not allowed to erase all of them (at least one number must remain).
For each remaining number, she may put either a
+or a-sign in front of it.
After that, Ana computes the sum of the remaining numbers. She wins the game if she can obtain a sum that is divisible by \(m\). Otherwise, Bob wins.
Given \(n\) and \(m\), determine which player has a winning strategy.
Input
The first line contains a single integer \(t\) – the number of test cases.
Each of the next \(t\) lines contains two integers \(n\) and \(m\).
Output
For each test case, output a single line.
Ana– if Ana has a winning strategy,Bob– if Bob has a winning strategy.
Constraints
\(1 \le t \le 10^5\),
\(1 \le n, m \le 10^{18}\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 3 1 2 2 3 3 8 | Bob Ana Bob |
Notes
In the first test case, Bob can choose \(a_1 = 3\).
In the second test case, no matter how Bob chooses \(a_1, a_2\), Ana has a winning strategy.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|