#include<bits/stdc++.h>      #define fill(arr,c) memset(arr,c,sizeof(arr))   #define perm(r) next_permutation(all(r))   //it gives bool value ans permute the string lexoggraphically   #define sortdesc greater<int>()   #define ll long long int    //std::setfill( 0 ) << std::setw(5) << 25; it adds leaing zeroes;   #define f(i,a) for(ll i=0;i<a;i++)   #define fo(i,a) for(ll i=1;i<=a;i++)   #define foo(i,x,n,c) for(ll i=x;i<n;i+=c)   #define foi(i,x,n,c) for(ll i=x;i>=n;i+=c)   #define fauto(i,m) for(auto i:m)   #define forall(a) for( auto itr=a.begin();itr!=a.end();itr++)   #define ld long double   #define in push_back   #define mll map<ll,ll>   #define mcl map<char,ll>   #define msl map<string,ll>   #define vi vector<int >   #define vl vector<ll >   #define vp vector< pair<int,int> >   #define vs vector <string>    #define vc vector <char>    #define o(a) cout<<a   #define os(a) cout<<a<<      #define en cout<<  n ;   #define testcase ll t ;cin>>t; while(t--)   #define ff first   #define ss second   #define pl pair<ll,ll>   #define pi pair<int,int>   #define all(a) (a).begin(), (a).end()      #define sz(a)  (a).size()   #define prec(n) fixed<<setprecision(n)   #define mp make_pair   #define bitcount  __builtin_popcountll   #define imin o( imin );en;   using namespace std;   bool comp(const pair<int,int> &a , const pair<int,int> &b){       if(a.first == b.first)  return a.second < b.second;        return a.first < b.first;   }   bool comps(const pair<int,int> &a , const pair<int,int> &b){       if(a.second == b.second)  return a.first< b.first;        return a.second < b.second;   }    bool prime[1000005];    void primeseries(ll n)   {          memset(prime, true, sizeof(prime));             for (ll p=2; p*p<=n; p++)        {            // If prime[p] is not changed, then it is a prime            if (prime[p] == true)            {                // Update all multiples of p greater than or                 // equal to the square of it                // numbers which are multiple of p and are                // less than p^2 are already been marked.                 for (ll i=p*p; i<=n; i += p)                    prime[i] = false;            }        }   //return prime;       }   struct custom_hash {       size_t operator()(uint64_t x) const {           static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();           x ^= FIXED_RANDOM;           return x ^ (x >> 16);       }   };   bool compmx(int a, int b)    {        return (a < b);    }    // bool isprime(int x){   //     for(int i = 2; i*i <= x; i++){   //         if(x%i == 0) return false;   //     }   //     return true;   // }   //   //ll pi=acos(0.0)*2;   void fastio()   {        ios::sync_with_stdio(0);   cin.tie(0);      }   ll mod=1E9+7;   void inout()   {          #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);           freopen( output.txt ,  w , stdout);        #endif   }   unsigned long long power(unsigned long long x,                                      int y, int p)   {       unsigned long long res = 1; // Initialize result           x = x % p; // Update x if it is more than or       // equal to p           while (y > 0)        {                   // If y is odd, multiply x with result           if (y & 1)               res = (res * x) % p;               // y must be even now           y = y >> 1; // y = y/2           x = (x * x) % p;       }       return res;   }       // Returns n^(-1) mod p   unsigned long long modInverse(unsigned long long n,                                                 int p)   {       return power(n, p - 2, p);   }       // Returns nCr % p using Fermat s little   // theorem.   unsigned long long nCr(unsigned long long n,                                    int r, int p)   {       // If n<r, then nCr should return 0       if (n < r)           return 0;       // Base case       if (r == 0)           return 1;           // Fill factorial array so that we       // can find all factorial of r, n       // and n-r       unsigned long long fac[n + 1];       fac[0] = 1;       for (int i = 1; i <= n; i++)           fac[i] = (fac[i - 1] * i) % p;           return (fac[n] * modInverse(fac[r], p) % p               * modInverse(fac[n - r], p) % p)              % p;   }   bool chk(ll i,ll a,ll b,ll n)    {    ll x=i*a+(n-i)*b;    bool r=true;    while(x)        {     if(x%10!=a && x%10!=b)     return false;     x/=10;    }    return true;   }   //ll a[1001][1001];      int main()   {   //fastio();   //os(1);;   testcase   {         ll n,m,u,v;   cin>>n>>m>>u>>v;   ll a[m];   f(i,m)   cin>>a[i];   sort(a,a+m);   f(i,m)   a[i]++;   ll ans=0;   if(u>v)   {    u=n-u+1;    v=n-v+1;   }   ll prev=m;   f(i,v)   {    ll x=upper_bound(a,a+prev,v-i-1)-a;    x--;    prev=x;    if(x>=0)    ans++;    else    break;   }   o(min(ans,v-u-1));      en;   }   return 0;   }