403199: GYM101064 F Metal detector
Description
Since the 2017 world finals will be in Rapid City, South Dakota, the MaratonIME's coach decides to visit the city to know the contest location.
The city is preparing to receive the best computer programmers in the world. To ensure the safety of the event, metal detectors are being installed at the entrance of the convention center where the contest will be held. To avoid long waits in the line, the security officers were instructed to send every person that activates the metal detector to the end of the line.
The coach noticed that one of the metal detectors is defective and it is always activated alternately. This means that the first person does not activate it and the next person does. The third person does not activate it and the next person does, and so on.
Given that there are N people in the line, the coach, that is the i-th in the line, wants to know when he will be able to go through the metal detector without activating it.
InputThe input starts with an integer T, the number of test cases.
Each test case consists of two integers, N and i, corresponding to the number of people in the line and the position of the coach in the line, respectively.
Limits
- 1 ≤ T ≤ 103
- 1 ≤ N ≤ 109
- 1 ≤ i ≤ N
For each test case, print a line with one integer j meaning that the coach will be the j-th person to go through the metal detector without activating it.
ExampleInput2Output
5 1
6 2
1
4