题目链接:https://codeforces.com/contest/2005/problem/B1
(开局看掉m=2和q=1)
include
include
using namespace std;
int main(){
long u;
cin>>u;
for(;u>0;u--){
long n;
long m,q;
long arr1[3];
long cha;
cin>>n>>m>>q;
for(int i=0;i<2;i++){
cin>>arr1[i];
}
sort(arr1,arr1+2);
cin>>cha;
long min;
if(arr1[0]>cha){
min=arr1[0]-1;
} else if(arr1[1]<cha){
min=n-arr1[1];
} else{
min=(arr1[1]-arr1[0])/2;
}
cout<<min<<endl;
}
return 0;}