#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
#define ll long long
#define pb push_back

int s[maxn];

int n, m, a, b;
int cnt;
int check(int x)
{
	int max1 = 0;
	int now = 1;
	for (int i = x; i >= 1; i--)
	{
		max1 = max(max1, now + s[i]);
		now++;
	}
	if (max1 > cnt)
		return 0;
	return 1;
}



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		cin >> n >> m >> a >> b;
		for (int i = 1; i <= m; i++)
			cin >> s[i];
		if (a < b)
			cnt = b - 1;
		else
			cnt=n - b;
		sort(s + 1, s + 1 + m);
		int ans = 0;
		int l = 1, r = min(m, abs(a-b) - 1);
		while (l <= r)
		{
			int mid = (l + r) / 2;
			if (check(mid))
			{
				l = mid + 1;
				ans = mid;
			}
			else
				r = mid - 1;
		}
		cout << ans << '\n';

	}





}

      	        	    	   	  			