#include<bits/stdc++.h>
using namespace std;
long long int MOD=1000000007; //998244353
long long int inverse(long long int i){
    if(i==1) return 1;
    return (MOD - ((MOD/i)*inverse(MOD%i))%MOD+MOD)%MOD;
}




int main()
{ int t;
cin >> t;
while(t--)
{
  int n,m,a,b;
  cin >> n>> m>>a>>b;
  int d[m];
  for(int i=0;i<m;++i)
  scanf("%lld" , d+i);
  sort(d,d+m);
  int f=min(abs(a-b)-1,m);
  int time1=(a<b)?b-1:n-b;
  int ans1=0,max1=-1;
  int flag1=0;
  for(int i=0;i<f;++i)
  {
    max1=max(max1+1,d[i]+1);
    if(max1>time1)
    {
      ans1=i;
      flag1=1;
      break;
    }

  }
  if(flag1==0)
  { ans1=f;

  int time2=abs(a-b);
  int max2=0;
  for(int i=min(m-1,f);i>-1;--i)
  { if(d[i]+min(m-1,f)-i+1>max2)
  max2=d[i]+min(m-1,f)-i+1;

  }
   if(max2<=time2)
   {
     ans1=max(min(m-1,f)+1,ans1);
   }

  }
  cout<<ans1<<"\n";
}
}
