P13893 [CodeChef] prys01
NOI
题目描述

Problem Statement
N knights were sitting at a round table and having a serious talk. The knights are so tired, that they can’t even rotate their neck to talk to talk to the knights sitting on their sides. So, a knight can only talk to the knight sitting diametrically opposite to him on the table.
Given the number of knights N, find the index of the knight sitting opposite to the knight numbered M. It is ensured that there is always a knight in front of the knight numbered M. Knights are indexed in clockwise manner from 1 to N.

Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains two space separated integers N and M denoting the number of knights and the index of knight for which answer is required.

Output
For each test case, output a single integer containing the required answer to the problem.

Constraints
1 ≤ T ≤ 100000
1 ≤ N ≤ 10^18
1 ≤ M ≤ N

Example
Input:
1
6 2

Output:
5

输入格式

见题面

输出格式

见题面

样例输入
1 6 2
样例输出
5