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

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int i = a; i < b; i++)
#define sz(x) (int)x.size()
#define fr first
#define sc second
#define all(a) a.begin(), a.end()


const int N = 18;
const ll INF = 1e18;

void solve() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  vector <int> s(m);
  rep(i, 0, m) cin >> s[i];
  sort(all(s));
  int canlit = min(abs(a - b) - 1, m);
  int have = 0;
  if(a < b) {
    have += b - 1;
  }
  else {
    have += (n - b);
  }
  int burst = 0;
  for(int i = canlit - 1; i >= 0; i--) {
    if(s[i] < have) {
      burst++;
      have--;
    }
  }
  cout << burst << "\n";
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

