#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t; cin >> t;
  while (t--)
  {
    ll n, m, a, b;
    cin >> n >> m >> a >> b;
    vector<ll> vec;
    for (ll i = 0; i < m; i++)
    {
      ll x; cin >> x;
      vec.push_back(x);
    }
    sort(vec.begin(), vec.end());
    ll fc = abs(a - b) - 1;
    ll maxy = 0;
    if (a < b) maxy = b - 1;
    else maxy = n - b;
    ll j = m - 1;
    ll ct = 0;
    while (j >= 0)
    {
      if (vec[j] < maxy) {maxy--; ct++;}
      j--;
    }
    ll res = min(ct, fc);
    cout << res << "\n";
  }
  return 0;
}