#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define pob pop_back()
#define ms0(s) memset(s,0,sizeof s)
#define ff first
#define ss second
typedef long long int ll;
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define prq priority_queue<ll>  //max-heap
#define psq priority_queue<ll,vector<ll>,greater<ll>>  //min-heap
#define m_p make_pair
#define vcc vector<char>
#define vss vector<string>
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define setbit(n) __builtin_popcountll(n)
const ll mxn = 0;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	cin >> t;
	while (t--)
	{
		ll i, j, k, n, m, a, b;
		cin >> n >> m >> a >> b;
		vll s(m);
		for (i = 0; i < m; i++)
			cin >> s[i];
		sort(all(s), greater<ll>());
		k = abs(b - a) - 1;
		ll time;
		if (a < b)
			time = b - 1;
		else
			time = n - b;
		ll ans = 0;
		for (i = 0, j = 1; i < m && j <= k; i++)
			if (s[i] + j <= time)
				ans++, j++;
		cout << ans << "\n";
	}
	return 0;
}