| Codeforces Round 1079 (Div. 1) |
|---|
| Finished |
Alice and Bob have two integers $$$p$$$ and $$$q$$$, and they are playing a game with these numbers. The players take turns, with Alice going first. On their turn, a player can do one of two actions:
The game ends when $$$p = 0$$$ and $$$q = 1$$$.
Bob wins if at any point during the game the fraction $$$\frac{p}{q}$$$ is equal to in value the fraction $$$\frac{2}{3}$$$. Otherwise, Alice wins.
Given the initial values of $$$p$$$ and $$$q$$$, determine the winner of the game if both players play optimally.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
Each input case consists of a single line containing two integers $$$p$$$ and $$$q$$$ ($$$1 \le p, q \le 10^{18}$$$).
For each input case, output:
64 610 1415 157 127000000000000000 104872757157825821000000000000000000 1000000000000000000
BobBobAliceAliceBobAlice
In the first input case, the fraction is already equal to $$$\frac{2}{3}$$$ by value, so Bob wins.
In the second input case, one possible sequence of the game is as follows:
Bob wins, as $$$\frac{8}{12}$$$ is equal to $$$\frac{2}{3}$$$. It can be shown that in this example, with optimal play from both players, Bob always wins.
For the third input case, Alice's optimal strategy will be to decrease $$$q$$$ as long as possible. In this case, the game will end in favor of Alice regardless of Bob's actions.
| Name |
|---|


