#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	 	// freopen("input.txt", "r", stdin);
  		// freopen("output.txt", "w", stdout);
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		ll t,i,j;
		
		cin>>t;
		while(t--)
		{
			ll n,m,a,b;
			cin>>n>>m>>a>>b;
			ll arr[m];
			// ll avail=0;
			for(i=0;i<m;i++)
			{
				cin>>arr[i];
			}
			sort(arr,arr+m);
			ll l = 0;
			ll r = min(m,abs(a-b)-1);
			ll avail=0;
			if(a<b)
			{
				avail = b-1;
			}
			else
			{
				avail = n-b;
			}
			
			while(r-l > -1)
			{
				ll mid = (l+r)/2;
				ll f= 0;


				for(i=mid-1;i>=0;i--)
				{
					j = mid - i;
					j += arr[i];
					j = avail - j;
					if(j<0)
					{
						f=1;
						break;
					}
				}
				if(f==1)
				{
					r = mid-1;
				}
				else
				{
					l = mid+1;
				}
			}
			cout<<r<<endl;
		}
		

	
	return 0;
}
