A. Chrome Tabs
time limit per test
2 seconds
memory limit per test
256 megabytes
input
tabs.in
output
standard output

Before participating in any online contest, you only keep the tab of the online contest open and close everything else.

You have n open tabs, numbered from 1 to n from left to right. Tab number k is the tab of the online contest and it is the current selected one. You have only two buttons:

  • Close all tabs to the left of the selected tab.
  • Close all tabs to the right of the selected tab.

What is the minimum number of clicks needed to close all tabs except tab number k?

Input

The first line of input contains a single integer T (1 ≤ T ≤ 5050), the number of test cases.

Each test case consists of a single line that contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 100), the number of open tabs, and the tab of the online contest, respectively.

Output

For each test case, print the minimum number of clicks needed to close all tabs except the tab of the online contest.

Example
Input
4
72 1
5 2
10 7
64 64
Output
1
2
2
1