You are the gym teacher in the school.

There are $n$ students in the row. And there are two rivalling students among them. The first one is in position $a$, the second in position $b$. Positions are numbered from $1$ to $n$ from left to right.

Since they are rivals, you want to maximize the distance between them. If students are in positions $p$ and $s$ respectively, then distance between them is $|p - s|$. 

You can do the following operation at most $x$ times: choose two adjacent (neighbouring) students and swap them.

Calculate the maximum distance between two rivalling students after at most $x$ swaps.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.

The only line of each test case contains four integers $n$, $x$, $a$ and $b$ ($2 \le n \le 100$, $0 \le x \le 100$, $1 \le a, b \le n$, $a \neq b$) — the number of students in the row, the number of swaps which you can do, and positions of first and second rivaling students respectively.


-----Output-----

For each test case print one integer — the maximum distance between two rivaling students which you can obtain.


-----Example-----
Input
3
5 1 3 2
100 33 100 1
6 0 2 3

Output
2
99
1



-----Note-----

In the first test case you can swap students in positions $3$ and $4$. And then the distance between the rivals is equal to $|4 - 2| = 2$.

In the second test case you don't have to swap students. 

In the third test case you can't swap students.

Difficulty: interview

Starter code:

Solutions:
for _ in range(int(input())):
	n, x, a, b = map(int, input().split())

	print(min(abs(a - b) + x, n - 1))

t = int(input())



for case in range(t):
    n, x, a, b = list(map(int, input().split()))
    dist = abs(b - a)
    ans = min(x + dist, n - 1)
    print(ans)

t = int(input())
for i in range(t):
    n, x, a, b = map(int, input().split())
    print(min(n - 1, abs(a - b) + x))

t=int(input())
for _ in range(t):
    n,x,a,b=map(int,input().split())
    a,b=min(a,b),max(a,b)
    print(min(x+abs(a-b),n-1))

t=int(input())
for i in range(t):
    n,x,a,b=[int(x) for x in input().split(' ')]
    print(min(n-1,abs(a-b)+x))


import sys
def I():
        return sys.stdin.readline().rstrip()

for _ in range(int(I())):
    n, x, a, b = list(map( int, I().split() ))
    a = abs( a - b )
    print( min( n - 1, a + x ) )


#    !/usr/bin/env python3
#    encoding: UTF-8
#    Last Modified: 13/Nov/19 08:07:04 PM


import sys


def main():
    for tc in range(int(input())):
        n, x, a, b = get_ints()
        a -= 1
        b -= 1
        if a > b:
            a, b = b, a
        while x > 0 and a > 0:
            x -= 1
            a -= 1
        while x > 0 and b < n - 1:
            x -= 1
            b += 1
        print(b - a)


get_array = lambda: list(map(int, sys.stdin.readline().split()))


get_ints = lambda: list(map(int, sys.stdin.readline().split()))


input = lambda: sys.stdin.readline().strip()


def __starting_point():
    main()

__starting_point()

for _ in range(int(input())):
    n,x,a,b = [int(i) for i in input().split(' ')]
    a,b = min(a,b),max(a,b)
    while x:
        if a>1:
            a-=1
        elif b<n:
            b+=1
        x-=1
    print(b-a)

t = int(input())
for i in range(t):
	n, m, a, b = list(map(int, input().split()))
	print(min(abs(a - b) + m, n - 1))


t = int(input())

for i in range(t):
	n, x, a, b = map(int, input().split())
	print(min(n - 1, abs(b - a) + x))

q = int(input())
for i in range(q):
    n, x, a, b = list(map(int, input().split()))
    print(min (abs(a - b) + x, n - 1,))


n = int(input())
for i in range(n):
    a, b, c, d = list(map(int, input().split()))
    print(min(abs(c - d) + b, a - 1))


import random


def get_many_ints():
    return list(map(int, input().split()))


def get_int():
    return int(input())


def get_int_list():
    return list(get_many_ints())


def prog():
    n, x, a, b = get_many_ints()
    if a > b:
        a, b = b, a
    da = min(a - 1, x)
    a -= da
    x -= da
    db = min(n - b, x)
    x -= db
    b += db
    print(b - a)


q = get_int()
for _ in range(q):
    prog()


for _ in range(int(input())):
	n,x,a,b=map(int,input().split())
	a,b=min(a,b),max(a,b)
	ad=max(1,a-x)
	x-=a-ad
	bd=min(n,b+x)
	print(bd-ad)

import sys
input = sys.stdin.readline

t=int(input())

for testcases in range(t):
    n,x,a,b=list(map(int,input().split()))

    ANS=abs(b-a)

    print(min(n-1,ANS+x))
    


'''
Created on 2019. 9. 21.

@author: kkhh88
'''
#q = int(input())
#x, y = map(int,input().split(' '))
#print (' '.join(list(map(str, s))))

q = int(input())

for i in range(q):
    n = list(map(int,input().split(' ')))
    if n[2] > n[3]:
        ans = n[2] - n[3]
    else:
        ans = n[3] - n[2]
    
    ans = ans + n[1]
    
    if ans >= n[0]:
        ans = n[0] - 1
    
    print (ans)




for _ in range(int(input())):
    n, x, a, b = list(map(int, input().split()))
    print(min(n - 1, x + abs(a - b)))


for _ in range(int(input())):
    n, x, a, b = list(map(int, input().split()))
    print(min(n-1, abs(a-b) + x))


t = int(input())
for i in range(t):
	n,x,a,b = list(map(int,input().split()))
	print(min(n-1,max(a,b)-min(a,b)+x))

q = int(input())
for re in range(q):
	n, x, a, b = map(int,input().split())
	if abs(a-b) + x >= n - 1:
		print (n - 1)
	else:
		print(abs(a-b) + x)

t = int(input())
for i in range (t):
    n, x, a, b = list(map(int,input().split()))
    print(min(n-1, max(a, b) - min(a, b) + x))

t = int(input())
for _ in range(t):
    n, x, a, b = map(int, input().split())

    ans = min(n-1, abs(a-b) + x)
    print(ans)

import math
import bisect
from collections import defaultdict as df
from collections import deque
from sys import stdin,stdout
t=int(input())
for i in range(t):
    n,x,a,b=list(map(int,input().split()))
    
    p=[a,b]
    p.sort()
    a,b=p
    room=a-1+n-b
    mini=min(room,x)
    ans=b-a+mini
    print(ans)
    


t = int(input())

for _ in range(t):
	n, x, a, b = map(int, input().split())

	print(min(n - 1, abs(a - b) + x))