#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define ld          long double

#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)

#define pfi(a)      printf("%d ", a)
#define pfl(a)      printf("%lld ", a)
#define el          printf("\n");
#define pfY         printf("YES\n")
#define pfN         printf("NO\n")
#define pfy         printf("Yes\n")
#define pfn         printf("No\n")

#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define pll         pair<ll,ll>
#define pii         pair<int, int>

#define pb          push_back
#define mk          make_pair
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define  all(v)     v.begin(), v.end()

#define md          1000000007
#define pi          acos(-1.0)

ll a,b, p[200010];
map<ll,ll>mp;
vector<ll>v;
vector<pll>vp;
string s,q;
char c;

int main()
{
    ll t,n,k,m,l,r,mn=0, mx=0,ans=0,nm=0,cnt=0,x,y,z;

    sl(t);
    while(t--)
    {
        cin>>n>>m>>a>>b;
        ll koyta=abs(a-b)-1;
        koyta=min(koyta, m);
        ll time;

        if(b>a) time=b-1;
        else time=n-b;

        for(int i=0; i<m; i++)
        {
            sl(p[i]);
        }
        sort(p,p+m);
        stack<ll>st;

        for(int i=0; i<m; i++)
            st.push(p[i]);

        ans=0;
       // cout<<time<<endl;
        for(int i=1; i<=koyta; i++)
        {

            //cout<<ans<<" "<<time<<endl;
            while(!st.empty() && st.top()+ i > time)
            {
                //cout<<"while "<< st.top()+i<<" "<<time<<" "<<i<<endl;
                st.pop();
            }
            if(st.empty()) break;

            //cout<<st.top()+i<<" "<<time<<" "<<i<<endl;
            ans++;
            st.pop();
            //time--;

        }

        //cout<<koyta<<endl;
        printf("%lld\n", ans);


    }
}



