#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;


void solve(){
   ll n,m,a,b;
   cin>>n>>m>>a>>b;
   vector<ll>v(m);
   for(int i=0;i<m;i++)cin>>v[i];
    ll time=0;
   ll num=(abs(b-a)-1);
   time+=num;
   if(b>a){
     time+=(a-1);
   }else time+=(n-a);
   ll sum=0;
   if(num<=0){
      cout<<0<<endl;
      return;
   }
   sort(v.begin(),v.end());

   int cnt=0;
   int ans=0;
   int x=num-1;
   //cout<<num<<endl;
   //cout<<time<<endl;
   for(int i=0;i<m;i++){

     if(cnt==num || x<0)break;
     ll y=time-v[i];
     if(y>=x){
      x--;
      ans++;
      cnt++;
     }else{
       if(y<0)break;
       x=y;
       x--;
       ans++;
       cnt++;
     }

   }
   cout<<ans<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int tests=1;
  cin>>tests;
  

  while(tests--){
   
    solve();

  }
}
