#P1488C. Two Policemen

    ID: 2486 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>*special problembinary searchbrute forcemath*1900

Two Policemen

Description

There is a street that can be represented as an array of length nn.

There are two policemen patrolling a street: the first one is standing at the point xx of the street and the second one is standing at the point yy of the street.

During one minute, both policemen can decide what to do (independently): move left (if the current position is greater than 11), move right (if the current position is less than nn), or do nothing.

The street is considered clear if each point of the street is visited by at least one policeman.

Your task is to find the minimum number of minutes the policemen need to visit each point of the street (again, each point should be visited by at least one of them).

You have to answer tt independent test cases.

The first line of the input contains one integer tt (1t21041 \le t \le 2 \cdot 10^4) — the number of test cases. Then tt test cases follow.

The only line of the test case contains three integers nn, xx and yy (2n1062 \le n \le 10^6; 1x,yn1 \le x, y \le n; xyx \ne y) — the length of the street, the position of the first policeman and the position of the second policeman, respectively.

It is guaranteed that the sum of nn does not exceed 10610^6 (n106\sum n \le 10^6).

For each test case, print one integer — the minimum number of minutes the policemen need to visit each point of the street.

Input

The first line of the input contains one integer tt (1t21041 \le t \le 2 \cdot 10^4) — the number of test cases. Then tt test cases follow.

The only line of the test case contains three integers nn, xx and yy (2n1062 \le n \le 10^6; 1x,yn1 \le x, y \le n; xyx \ne y) — the length of the street, the position of the first policeman and the position of the second policeman, respectively.

It is guaranteed that the sum of nn does not exceed 10610^6 (n106\sum n \le 10^6).

Output

For each test case, print one integer — the minimum number of minutes the policemen need to visit each point of the street.

Sample Input 1

6
4 1 2
7 7 1
10 2 6
8 5 2
2 1 2
20 4 14

Sample Output 1

2
3
5
4
0
12