You are given two positive integers, $$$a$$$ and $$$b$$$ ($$$a < b$$$).
For some positive integer $$$n$$$, two players will play a game starting with a pile of $$$n$$$ stones. They take turns removing exactly $$$a$$$ or exactly $$$b$$$ stones from the pile. The player who is unable to make a move loses.
Find a positive integer $$$n$$$ such that the second player to move in this game has a winning strategy. This means that no matter what moves the first player makes, the second player can carefully choose their moves (possibly depending on the first player's moves) to ensure they win.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows.
The only line of each test case contains two integers, $$$a$$$ and $$$b$$$ ($$$1 \le a < b \le 100$$$).
For each test case, output any positive integer $$$n$$$ ($$$1 \le n \le 10^6$$$) such that the second player to move wins.
It can be proven that such an $$$n$$$ always exists under the constraints of the problem.
31 41 59 26
2 6 3
In the first test case, when $$$n = 2$$$, the first player must remove $$$a = 1$$$ stone. Then, the second player can respond by removing $$$a = 1$$$ stone. The first player can no longer make a move, so the second player wins.
In the second test case, when $$$n = 6$$$, the first player has two options:
In the third test case, the first player cannot make any moves when $$$n = 3$$$, so the second player immediately wins.
Name |
---|