#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    multiset<int>s;
    cin>>t;
    while(t--){
    	s.clear();
    	ll n,m,a,b;
    	cin>>n>>m>>a>>b;
    	for(int x,i=0;i<m;i++){
    		cin>>x;
    		s.insert(-x);
    	}
    	ll has,tot,ned;
    	if(a<b){
    		tot=b-1;
    		ned=a-1;
    	    has=tot-ned;
    	}
    	else {
    		tot=n-b;
    		ned=n-a;
    		has=tot-ned;
    	}
    	ll dif=abs(a-b)-1;
    	has-=dif;
    	int ans=0;  
    	for(int i=1;i<=min(dif,m);i++){
    		ll ned=tot-i;
    		auto it1=s.lower_bound(-ned);
    		auto it=*s.lower_bound(-ned);
    		if(it1==s.end())continue;
    		if(it>=-1*ned){
    			ans++; 
    			s.erase(s.find(it));
    		}
    	}
    	if(s.size()>0&&ans==dif){
    		int cur=tot-has+1;
    		while(1){
    			if(s.size()==0||has==0)break;
    			ll ned=tot-cur;
    			cur++;
	    		auto it1=s.lower_bound(-ned);
	    		auto it=*s.lower_bound(-ned);
	    		if(it1==s.end())break;
	    		if(it>=-1*ned){
	    			ans++; 
	    			s.erase(s.find(it));
	    		} 
    		}
    	}
    	cout<<ans<<'\n';
    }
}