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

#define l long long
#define mod 1000000007
#define ii pair<l,l>


class problem {

public:
	void solve(){
		int t;cin>>t;
		while(t--){
			l n,m,a,b;
			cin>>n>>m>>a>>b;

			l numberOfCrackersExploded = abs(a-b)-1;
			l maxTimeToExplode = (a<b?(b-2):(n-b-1));
			l ar[m];
			for(int i=0;i<m;i++)cin>>ar[i];
			sort(ar,ar+m);
			l finalAns=0;
			for(int i=m-1;i>=0;i--){
				if(ar[i]<=maxTimeToExplode){
					finalAns++;
					maxTimeToExplode--;
				}
			}
			cout<<min(finalAns,numberOfCrackersExploded)<<endl;
		}
	}
};

int main()
{
	problem p;
	p.solve();
}

