404677: GYM101608 A Chrome Tabs

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Chrome Tabstime limit per test2 secondsmemory limit per test256 megabytesinputtabs.inoutputstandard 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.

ExampleInput
4
72 1
5 2
10 7
64 64
Output
1
2
2
1

加入题单

上一题 下一题 算法标签: