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

using ll = long long;
using LL = long long;
using i64 = long long;

void solve() {
	int n; cin >> n;
	int k; cin >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(begin(a), end(a));
	int cnt = 0;
	for (int i : a)
		cnt += (i >= k);

	auto works = [&](int x) -> bool {
		if (2*x > n) return false;
		for (int i = 0; i < x; ++i)
			if (a[i] + a[2*x - 1 - i] > k)
				return false;
		return true;
	};
	int l = 0, r = n;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (works(m))
			l = m;
		else
			r = m;
	}
	int cp = min(n / 3, l);

	int ans = max({cnt, (n + 2) / 3, (n - 3 * cp + 1) / 2}) - 1;
	cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int t; cin >> t;
    while (t--) solve();
}