You are given a sorted array(arr) of size n consisting of distinct numbers from 1 to n (inclusive). You are given two positions p and q and you are allowed to do atmost k moves. A legal move is described as follows:
Note here consecutive means picking two positions i and j such that ∣i−j∣ = 1
You are required to maximise the distance between arr[p] and arr[q] with atmost k legal moves and output the maximum distance. You have to answer t testcases.
Constraints:
1≤t≤100
2≤n≤100,0≤k≤100,1≤p,q≤n,p≠q
Input format:
First line is the number of testcase t to be answered. The next t lines is of the format n,k,p,q.
Output format:
Output the maximum distance possible after k swaps.
No explanation for problems where you need to come up with an optimal way