#include <bits/stdc++.h>
using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << "  " << H; dbg_out(T...); }

#ifdef SMIE
#define debug(args...) cerr << "(" << #args << "):", dbg_out(args)
#else
#define debug(args...)
#endif

int main() {
    ios_base::sync_with_stdio(false); //don't mix C and C++ input output
    cin.tie(NULL);                   //remove line for interactive problem

    int tests;
    cin >> tests;

    while (tests-- > 0) {
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        vector<int> fire(m);
        for (int &s : fire) {
            cin >> s;
        }

        sort(fire.begin(), fire.end());

        int ans = 0, totalTime, dropTime, curTime = 1;

        if (a < b) {
            totalTime = b - 1;
            dropTime = b - a - 1;
        }
        else {
            totalTime = n - b;
            dropTime = a - b - 1;
        }

        debug(totalTime, dropTime);

        for (int i = m - 1; i >= 0 and dropTime > 0; i--) {
            if (curTime + fire[i] <= totalTime) {
                ans++;
                curTime++;
                dropTime--;
            }
        }

        cout << ans << '\n';
    }
}

