    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
     
     
    #define tc(t) int t; cin >> t;while(t--)
    #define lp(i, x, y) for(ll i = x; i <= y; i++)
    #define lpr(i, x, y) for(ll i = x; i >= y; i--)
    #define in1(x) ll x; cin >> x
    #define in2(x, y) ll x, y; cin >> x >> y
    #define in3(x, y, z) ll x, y, z; cin >> x >> y >> z
    #define mem(x, y) memset(x, (y), sizeof(x))
    #define ite(it, l) for (auto it = l.begin(); it != l.end(); it++)
    #define sortbaby(x) sort(x.begin(),x.end());
     
    bool done[1000000]={0};
    struct cmp{
        bool operator()(const pair<ll,ll>& a,const pair<ll,ll>& b)
        {
            if(a.first!=b.first) return a.first>b.first;
            return a.second>b.second;
        }
    };
    // Driver code
    int main()
    {
        fastio
      //cin.tie(0); cout.tie(0); freopen("homework.in", "r", stdin); freopen("homework.out", "w", stdout);
        tc(t)
        {
            in3(n,m,a);
            in1(b);
            ll bw,end;
            if(a<b)
            {
                bw=b-a-1;
                end=b-1;
            }
            else
            {
                bw=a-b-1;
                end=n-b;
            }
            vector<ll> crackers;
            lp(i,1,m)
            {
                in1(x);
                crackers.push_back(x);
            }
            
            ll ans=0;
            sortbaby(crackers);
            auto last=crackers.end();
            lp(i,1,bw)
            {
                
                bool found=0;
                auto it=lower_bound(crackers.begin(),last,end);
                if(it==crackers.begin() && *it > end)
                    break;
                // if(it!=crackers.end() && *it==end)
                // {
                //     ans++;
                //     end--;
                //     it=crackers.erase(it);
                //     continue;
                // }
                if(it!=crackers.begin())
                {
                    it--;
                   // printf("i %lld *it %lld end %lld",i,*it,end);
                    //cout<<endl;
                    fflush(stdout);
                    if(*it<end){
                        ans++;
                        last=it;
                        if(it==crackers.begin())
                            break;
                    }
                    end--;
                }
            }
            cout<<ans<<endl;
        }
    }