#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vvi vector<vector<int>>
#define mi  map<int,int>
#define mii map<pii,int>
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define sz(x) (int)x.size()
#define all(v) (v).begin(), (v).end()
#define ret(x) return cout<<x,0;
#define rety return cout<<"Yes",0;
#define retn return cout<<"No",0;
#define fl fflush(stdout)   
#define hell 1000000007
#define hell2 998244353 
#define pi 3.14159265358979323846

int fexp(int a, int b,int m){int ans = 1;while(b){if(b&1)ans=ans*a%m; b/=2;a=a*a%m;}return ans;}
int inverse(int a, int p){return fexp(a, p-2,p);} 

int fac[300005]; //fac[0]=1;fac[1]=1;rep(i,2,100005)fac[i]=(fac[i-1]*i)%hell;

int ncr(int n, int r,int p) { 
    if (r==0) return 1; 
    return (fac[n]*inverse(fac[r],p)%p*inverse(fac[n-r],p)%p)%p; 
}

bool sortby(pii &a,pii &b){
    if(a.ff==b.ff)return (a.ss<b.ss);
    return (a.ff<b.ff);
}
int n,m,a,b;

int check(int x,vi &s){
    int aa=a,bb=b;
    int d;
    if(a<b){
        bb-=x;
        if(bb<=aa)return 0;
        int z=0,t=x;
        repn(i,x,1){
            t--;
            z=max(z,(s[i]-t));
            //bb--;
        }
     //   cout<<x<<" "<<z<<"\n";
        if(z<=bb-1)return 1;
        return 0;
        d=b-1;
    }
    else{
        bb+=x;
        if(bb>=aa)return 0;
        int z=0,t=x;
        repn(i,x,1){
            t--;
            z=max(z,(s[i]-t));
           // bb++;
        }
        d=n-bb;
        if(z<=d)return 1;
        return 0;
    }
    //if(s<d||((x>1)&&(s==d)))return 1;
    return 0;
}

int solve(){
    //int n,m,a,b;
    cin>>n>>m>>a>>b;

    vi s(m+1);
    rep(i,0,m)cin>>s[i];
    s[m]=0;
    sort(all(s));
   // rep(i,1,m+1)s[i]+=s[i-1];
    int l=0,r=m,ans=0;
    while(l<=r){
        int m=(r+l)/2;
        if(check(m,s)){
            ans=max(ans,m);
            l=m+1;
        }
        else{
            r=m-1;
        }
    }
    cout<<ans;
    return 0;   
}

signed main(){
    auto start = high_resolution_clock::now();
    IOS;
    int t=1;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    cin>>t;
    //fac[0]=1;fac[1]=1;rep(i,2,100005)fac[i]=(fac[i-1]*i)%hell;
    while(t--){
        solve();
        cout<<"\n";
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr<<"Time taken:"<<duration.count()/1000000.0<<"seconds"<<"\n";
    return 0;
}