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

using namespace std;

int main() {
	int T;
	cin >> T;
	while (T--) {
		int n, m, a, b;
		cin >> n >> m >> a >> b;
		if (a > b) {
			a = n - a + 1;
			b = n - b + 1;
		}

		vector<int> fires;
		for (int i = 0; i < min(b - a - 1, m); i++) {
			fires.push_back(b - 2 - i);
		}
		reverse(fires.begin(), fires.end());

		vector<int> s(m);
		for (auto& si : s) cin >> si;
		sort(s.begin(), s.end());
		
		int ans = 0;

		for (int i = m - 1; i >= 0; i--) {
			if (fires.size() == 0) break;
			if (fires[fires.size() - 1] >= s[i]) {
				fires.pop_back();
				ans += 1;
			}
		}
		cout << ans << '\n';
	}

}