/*_आशीष_*/  
// उतिष्ठत। जाग्रत। प्राप्य वरान्निबोधत।    
#include <bits/stdc++.h>
using namespace std;

#define M                    1000000007
#define pi                   3.14159265358979323846
#define cel(x,a)             (x+a-1)/a
#define ll                   long long
#define pii                  pair<int, int>
#define pll                  pair<ll, ll>
#define vi                   vector<int>
#define vl                   vector<ll>
#define vpi                  vector<pii>
#define vpl                  vector<pll>
#define pb                   push_back
#define lb                   lower_bound
#define ub                   upper_bound
#define Uchchaihshrava       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl                 "\n"
#define ps(x,y)              fixed<<setprecision(y)<<x
#define pf(x,y)              setfill('x')<<setw(y)
#define mp                   make_pair
#define F                    first
#define S                    second
#define countofbits(n)       __builtin_popcount(n)
#define lcm(m,n)             (m/__gcd(m,n))*n
#define all(v)               v.begin(), v.end()

//bool sortbyi(const tuple<int, int, int>& a,const tuple<int, int, int>& b) 
//      {   return (get<i>(a) < get<i>(b));} 

//bool sortby(const pair<ll,ll> &a,const pair<ll,ll> &b) 
//{return (a.F<b.F);}

void cline()          { cout << '\n';}
template <typename T, typename... V>
void cline(T t, V... v) {cout << t; if (sizeof...(v))cout << ' '; cline(v...);}
void cspc()          { cout << ' ';}
template <typename T, typename... V>
void cspc(T t, V... v) {cout << t; if (sizeof...(v))cout << ' '; cspc(v...);}

const int N = 1e6 ;

int main()
{   
    Uchchaihshrava
  
//    freopen("input.txt", "r", stdin); 
//    freopen("output.txt", "w", stdout); 
  
    int q;cin>>q;
    while (q--){
int n,m,a,b;
cin>>n>>m>>a>>b;

int maxtym=0,end=0;

if(a<b)
    maxtym=b-1;
else
    maxtym=n-b;
maxtym;
int ar[m];

for(int i=0; i<m; i++)cin>>ar[i];

    int sz=m;
    sort(ar,ar+sz);

    int ans=0;

for(int i=min(m,abs(b-a)-1); i>0; i--)
{
    int j=ub(ar,ar+sz,maxtym-1)-ar;
   j--; //cline(sz,j,maxtym);
   maxtym--;
if(j<0)
   {break;}
else
   { ans++;sz=j;}
}
   cline(ans);
    }
    return 0;
}