#include <bits/stdc++.h> using namespace std; using ll = long long; using LL = long long; using i64 = long long; void solve() { ll n,k; cin >> n >> k; vector <ll> v(n); for (int i = 0; i < n; i++)cin >> v[i]; sort(v.begin(), v.end()); ll used_3 = 0; ll cur = n-1; vector <bool> used(n, 0); for (int i = 0; i < cur; i++){ if (n-2*used_3 <= used_3)break; while (cur > i && v[i]+v[cur] >= k)cur--; if (cur <= i)break; used[i] = 1; used[cur] = 1; cur--; used_3++; } vector <ll> a; for (int i = 0; i < n; i++)if (!used[i])a.push_back(v[i]); for (int i = 0; i < used_3; i++){ if (a.empty())break; a.pop_back(); } ll coun_small = 0; for (int i = 0; i < a.size(); i++)if (a[i] < k)coun_small++; ll tot = coun_small; ll boh = a.size(); tot = max(coun_small, coun_small + boh - 2*coun_small); //cout << used_3 << " " << coun_small << " " << boh << "\n"; cout << tot+used_3-1 << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) solve(); }