1180: Elevator

Memory Limit:256 MB Time Limit:1.000 S Judge Style:Text Compare Creator:
Submit:45 Solved:25

Description


There are lns="http://www.w3.org/1998/Math/MathML">
 people in elevator(电梯).  Each person has chosen a floor they wish to alight(下电梯) at. When the elevator stops at any given floor, all those who have selected that floor will exit the elevator.

In this scenario, lns="http://www.w3.org/1998/Math/MathML">
 unique(去重后) floors have been selected. Your task is to determine the maximum possible number of people, including yourself, who could leave the elevator on the floor you have chosen.



不允许普通用户打印题目,请教师登录后使用。如有疑问请联系管理员!

Input

The first line contains one integer T (1≤T≤10^4 ), indicating the number of test cases. 

For each test case, only one line contains two integers n,m (1≤m≤n≤10^4 ), indicating the number of people in the elevator and the number of unique selected floors, respectively.

Output

For each test case, output one integer in a single line, indicating the maximum number of people who could leave the elevator at the floor you have chosen.

Sample Input Copy

1
6 3

Sample Output Copy

4