#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define be(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(be(a),x)-a.begin())
#define ub(a,x) (upper_bound(be(a),x)-a.begin())
#define uniq(a) a.resize(unique(be(a))-a.begin())
#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);using namespace std;
using namespace std;
ll t,n,m,a,b,ar[200009],l,r,md,ans;
bool f(ll x){
    if(!x)return 1;
    for(ll i=1,j=x;i<=x;i++,j--){
        if(ar[i]+j>=b)return 0;
    }
    return 1;
}
int main(){
    cin>>t;
    while(t--){
        cin>>n>>m>>a>>b;
        for(int i=1;i<=m;i++)cin>>ar[i];
        sort(ar+1,ar+1+m);
        if(a>b){
            a=n-a+1;
            b=n-b+1;
        }
        l=0,r=min(m,b-a-1);
        while(l<=r){
            md=(l+r)/2;
            if(f(md)){
                l=md+1,ans=md;
            }
            else {
                r=md-1;
            }
        }
        cout<<ans<<endl;
    }
}
