#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int n,m,a,b;
	    cin>>n>>m>>a>>b;
	    vector<int> bomb(m);
	    for(int i=0;i<m;i++)cin>>bomb[i];
	    sort(bomb.begin(),bomb.end());
	    if(a>b)
	    {
	        a = n-a+1;
	        b = n-b+1;
	    }
	    int cnt = b-a-1;
	    if(cnt==0)cout<<"0\n";
	    else
	    {
	        cnt = min(cnt,m);
	        int ans=0,steps=b-1;
	        int upto = upper_bound(bomb.begin(),bomb.begin()+cnt,steps)-bomb.begin()-1;
	        for(;upto>=0;upto--)
	        {
	            if(bomb[upto]<steps)
	            {
	                ans++;
	                steps--;
	            }
	        }
	        cout<<ans<<"\n";
	    }
	}
	return 0;
}
