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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()
#define ff first
#define ss second
#define endl '\n'

const double pi=3.1415926535897932384626433832795;
const int inf=1e9;
const ll inf2=1e18;
const int mod=1e9+7;

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
    ll n,m,a,b;
    cin>>n>>m>>a>>b;
    ll dist=abs(b-a)-1LL;
    ll time=dist;
    if(a<b)
        time+=a-1LL;
    else
        time+=n-a;
    // cout<<time<<endl;
    vll arr(m);
    fr(i,0,m){
        cin>>arr[i];
    }
    sort(all(arr));
    int ans=0;
    for(int i=min(dist-1,m-1),j=0;i>=0;i--){
        if(arr[i]+j<=time){
            // cout<<arr[i]+j<<endl;
            ans++;
            j++;
        }
    }
    cout<<ans<<endl;
    return;
}

int main()
{
    boost();
    
    int tc=1;
    cin>>tc;
    while(tc--)
        solve();
    return 0;
}