#include <bits/stdc++.h>

#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define w(x) int x; cin >> x; while(x--)
#define forn(i, n) for(int i = 0; i < n; ++i)
#define int long long
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define endl '\n'

using namespace std;

int32_t main()
{
    FIO
    int n, m, a, b;
    w(t)
    {
    	cin >> n >> m >> a >> b;
    	vi s(m);
    	forn(i, m) cin >> s[i];
    	sort(all(s));
        vi ss;
    	int ans = 0, t = a < b ? b - 1 : n - b;
        forn(i, sz(s))
            if (s[i] + 1 > t)
                break;
            else
                ss.pb(s[i]);
        sort(allr(ss));
        int tmp = 0;
    	forn(i, sz(ss))
    	{
            if (ans == abs(a - b) - 1)
                break;
    		while (ss[i] + i + 1 - tmp > t)
            {
                i++, tmp++;
                if (i == sz(ss))
                    break;
            }
    		if (i < sz(ss))
                ans++;
    	}
    	cout << ans << endl;
    }
    return 0;
}