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

typedef long long ll;

#ifdef DEBUG
    #define var(x) cerr << #x << ": " << x << '\n';
    #define range(a, b) cerr << #a <<", " << #b << ": "; for (auto _it = a; _it != b; ++_it) cerr << *_it << ' '; cerr <<'\n';
#else
    #define cerr if (false) cerr
    #define var(x)
    #define range(a, b)
#endif

#define pii pair<int, int>
#define F first
#define S second
#define T(x, i) get<i>(x)
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < n; i++)

const int MAXN = 1e6 + 10;
int n, k;
int a[MAXN];

void solve() {
    forn(i, n) {
        cin >> a[i];
    }
    sort(a, a+n);
    int ans = 0;
    multiset<int> active;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] >= k) {
            active.insert(a[i]);
            continue;
        }
        auto it = active.upper_bound(k - a[i] - 1);
        if (it == active.begin()) {
            active.insert(a[i]);
            continue;
        }
        --it;
        active.erase(it);
        if (active.size() > 0) {
            active.erase(active.find(*active.rbegin()));
        } else {
            i--;
        }
        ans++;
    }
    while (active.size() > 0) {
        int x = *active.begin();
        active.erase(active.begin());
        if (x >= k) {
            ans++;
            continue;
        }
        if (active.size() > 0) active.erase(active.find(*active.rbegin()));
        ans++;
    }
    ans--;
    cout << ans << '\n';
}

signed main() {
    #ifdef DEBUG
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (cin >> n >> k) solve();
}