PRANAVHPTC - A very hard problem to crack

no tags 

Mujahid and Hasan went to Mirpur National Stadium to enjoy Bangladesh vs India cricket game.

There are N seats in total, but the seats are arranged in a circular way.

In the mean time Mujahid lost Hasan. But Mujahid has been able to Locate Hasan over Mobile Phone.

Now Mujahid wants to know minimum distance between them. Can you help him ???

Mujahid's Location is A, Hasan's Location is B.

Input

The first line contains positive integer t (1 ≤ t ≤ 1000) — the number of test cases. Next t lines contain the descriptions of test cases.

Each line contains three positive integer N, A, B. (1 <= N <= 10^14).

Output

For each testcase print a number which will be the minumum distance between Mujahid and Hasan's position.

For more understanding see the picture below, which is for the testcase where, N = 9, A = 2, B = 4.

Example

Input:
4
9 1 3
8 4 5
5 1 2
8 2 4

Output:
2
1
1
2


Added by:Mozahid
Date:2019-12-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All