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

const int maxn = 2e5 + 10;
int t, arr[maxn], n, m, a, b;

bool check(int k) {
    int x = abs(a - b) - 1;
    
    if (x < k) {
        return false;
    }
    
    int s = 0;
    
    if (a > b) {
        s = n - a;
    } else {
        s = a - 1;
    }
    
    for (int i = k - 1; i >= 0; i--) {
        if (arr[i] > x - (k - 1 - i) + s) {
            return false;
        }
    }
    
    return true;
}

int main () {
    cin >> t;
    
    while (t--) {
        cin >> n >> m >> a >> b;
        
        for (int i = 0; i < m; i++) {
            cin >> arr[i];
        }
        
        sort(arr, arr + m);
        
        int l = 0, r = m + 1;
        
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (check(mid)) {
                l = mid;
            } else {
                r = mid;
            }
        }
        
        cout << l << "\n";
    }
    
    return 0;
}