#include <bits/stdc++.h>

#define rep(i, l, r) for (int i = l, i##end = r; i <= i##end; ++i)
#define repo(i, l, r) for (int i = l, i##end = r; i < i##end; ++i)
#define per(i, l, r) for (int i = r, i##end = l; i >= i##end; --i)
bool dbg = true;
#define debug(x) if (dbg) cout << #x << ":\t" << (x) << endl;
#define here if (dbg) printf("Passing [%s] in Line %d", __FUNCTION__, __LINE__);
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> Pair;
typedef pair<int, int> P;
#define ll long long

const int maxn = 2e5 + 10;
const int N = 2e6 + 10;
const LL inf = 0x3f3f3f3f3f3f3f3f;

int T, n, m, a, b, s[maxn];

int solve() {
    if (a > b) {
        a = n - a + 1;
        b = n - b + 1;
    }
    sort(s + 1, s + m + 1);
    int rst = 0, tar = b;
    rep (i, 1, b - a - 1) {
        if (!m) break;
        while (m && i + s[m] >= tar) {
//            debug(i + s[m])
            --m;
        }
        if (m) {
            rst++;
            --m;
        }
    }
    return rst;
}

int main() {
    scanf("%d", &T);
    while (T--) {
        scanf("%d%d%d%d", &n, &m, &a, &b);
        rep (i, 1, m) scanf("%d", &s[i]);
        printf("%d\n", solve());
    }
    return 0;
}
