#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1) 
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a) emplace_back(a)
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

ll max(ll a,ll b)
{
	return (a>b) ? a : b;
}
ll min(ll a,ll b)
{
	return (a<b) ? a : b;
}
int main()
{
	FAST_IO ;
	int t;
	cin>>t;
	while(t--)
	{
		ll i,j,k,n,m,a,b;
		cin >> n >> m >> a >> b;
		vector<ll>arr(m);
		f(i,0,m)
			cin >> arr[i];
		sort(all(arr));
		ll time;
		if(b>a)
			time = b-1;
		else
			time = n-b;
		ll ans = 0;
		ll lb = 0;
		ll ub = min(max(a,b) - min(a,b) - 2,m-1);
		while(lb<=ub)
		{
			ll mid = (lb + ub)/2;
			j = 1;
			k = 0;
			for(i=mid;i>=0;i--)
			{
				if(arr[i]+j<=time)
					k++;
				else
					break;
				j++;
			}
			ans = max(ans,k);
			if(k==mid+1)
			{
				ans = max(ans,k);
				lb = mid+1;
			}
			else
				ub = mid-1;
		}
		cout << ans endl;
	}
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

//#define _GLIBCXX_DEBUG 
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv" 
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere
