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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int N = 1e5 + 5;
const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;

void solve()
{
   int  n, m, a, b;
   cin >> n >> m >> a >> b;
   vector<int> s(m);
   for (int i = 0; i < m; i++)
   {
      cin >> s[i];
   }
   sort(all(s));
   int totalTime, Crecked;
   if (a < b)
   {
      totalTime = b - 1;
      Crecked = b - a - 1;
   }
   else
   {
      totalTime = n - b;
      Crecked = a - b - 1;
   }
   int Fired = 0;
   for (int i = m - 1; i >= 0; i--)
   {
      if (Crecked > 0 && s[i] <= totalTime - Fired - 1)
      {
         Crecked--;
         Fired++;
      }
   }
   cout << Fired << endl;
}

int32_t main()
{
   IOS;
   int t = 1;
   cin >> t;
   for (int i = 1; i <= t; i++)
   {
      //cout<<"Case #"<<i<<": ";
      solve();
   }
   return 0;
}
