There are $$$N$$$ players participating in a game involving a glass bridge. The bridge consists of $$$M$$$ steps, and each step has two glass panels: one is safe, and the other is fragile and will break if stepped upon.
The players cross the bridge one at a time, following their position in a queue from $$$1$$$ to $$$N$$$. The rules are as follows:
Every player is rational and will use all information revealed by previous players. If a player reaches a step where the safe panel is unknown, they will choose one of the two panels with a $$$50\%$$$ probability of success.
You have the chance to bribe the organizers to pick any starting position from $$$1$$$ to $$$N$$$. Your goal is to choose the position $$$k$$$ that maximizes your probability of being the sole winner. If multiple positions yield the same maximum probability, choose any such $$$k$$$.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^5$$$) — the number of test cases.
Each test case consists of a single line containing two integers:
For each test case, output a single integer — the optimal position $$$k$$$ ($$$1 \le k \le N$$$) to maximize your winning probability.
31 12 23 3
123
The following diagram illustrates the glass bridge for the second test case:
For the second test case, if you start at position $$$1$$$ in the queue, then you must correctly choose the safe panel on both steps. Since each unknown step has a success probability of $$$1/2$$$, your probability of winning is:
$$$$$$ \frac{1}{2} \times \frac{1}{2} = \frac{1}{4} = 25\%. $$$$$$
However, if you start at position $$$2$$$, there are two cases where you win:
Hence, the total probability of winning when starting at position $$$2$$$ is:
$$$$$$ \frac{1}{4} + \frac{1}{4} = \frac{1}{2} = 50\%. $$$$$$
| Название |
|---|


