#include <bits/stdc++.h>
using namespace std;
#define pb  push_back
#define ll  long long
#define vi  vector<ll >
#define vvi vector<vi >
#define all(x) x.begin(), x.end()

int n, m, i, j, t;
vi  v;

bool ok(int k) {
    for (int i = 0; i < k; ++i)
        if (v[i] + k - i - 1 >= t)
            return false;
    return true;
}

int f() {
    cin >> n >> m >> i >> j; --i; --j;
    v.resize(m);
    for (auto& x : v)
        cin >> x;
    sort(all(v));
    m = min(abs(i - j) - 1, m);
    t = (i < j ? j : n - j - 1);
    int l = 0;
    int r = m + 1;
    while (r - l > 1) {
        int mi = (r + l) / 2;
        (ok(mi) ? l : r) = mi;
    }
    return l;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while (t--)
        cout << f() << "\n";

    return 0;
}