#include <bits/stdc++.h>

using namespace std;

//#define int long long

typedef long long ll;
typedef long double ld;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> lst(n);
    for (int i= 0; i < n; i++) {
        cin >> lst[i];
    }
    sort(lst.begin(), lst.end());
    vector<int> used(n, 0);
    int r = 0;
    while (r != n -1 && lst[r + 1] < k) {
        r++;
    }
    int ans = 0, mx = n - 1;
    int cnt = 0;
    for (int i =0; i < n; i++) {
        if (used[i]) continue;
        used[i] = 1;
        cnt++;

        if (lst[i] >= k) {
            if (cnt != n) {
                ans++;
            }
            continue;
        }
        while (r > i && (lst[i] + lst[r] >= k || used[r])) r--;

        if (r <= i) {
            while (mx > i && used[mx]) {
                mx--;
            }
            if (!used[mx]) {
                used[mx] = 1;
                cnt++;
            }
            if (cnt != n) {
                ans++;
            }
            continue;
        }
        used[r] = 1;
        cnt++;
        while (mx > i && used[mx]) {
            mx--;
        }
        if (!used[mx]) {
            used[mx] = 1;
            cnt++;
        }
        cerr << i << " " << r << " " << mx << " " << cnt << ' ' << ans << '\n';
        if (cnt != n) ans++;
    }
    cout << ans << '\n';

}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LC
    freopen("/home/team11/CLionProjects/contest/input.txt", "r", stdin);
    freopen("/home/team11/CLionProjects/contest/output.txt", "w", stdout);

#endif
    int t= 1 ;
    cin >> t;
    for (int tt =0; tt <t; tt++) {
        solve();
    }
    return 0;
}