#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define pll pair <ll, ll>
typedef long long ll; 
ll const N = 1e6+5, mod = 1e9+7, inf = 1e17; 
ll c[N], d[N], dp[N];
vector <ll> vec;
pll p[N];
int main () {
    ios::sync_with_stdio(false); cin.tie();
    ll t; cin >> t;
    while (t--) {
        ll n, m, a, b, ans = 0, f; cin >> n >> m >> a >> b;
        for (int i = 1; i <= m; i++) {cin >> c[i];}
        if (a < b) f = a - 1 + b - a;
        else  f = n - a + a - b;
        ll k = abs (a-b)-1;
        sort (c+1, c+m+1);
        while (m > 0) {
            f--;
            while (m != 0 && c[m] > f) {m--;}
            if (m != 0 && k) {
                k--;
                ans++;
            }
            m--;
        }
        cout << ans << endl;
    }

}