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

void solve() {
    int N, K;
    std::cin >> N >> K;
    std::vector<int> V(N);
    for (int& x : V) {
        std::cin >> x;
    }


    std::sort(V.begin(), V.end());
    std::multiset<std::pair<int, int>> MS;
    for (int i = 0; i < N; i++) {
        MS.emplace(V[i], i);
    }

    int r = 2 * N / 3 - 1;
    int answer = 0;

    for (int l = 0; l < r; l++) {
        while (l <= r && V[l] + V[r] >= K) {
            r--;
        }

        if (l <= r && V[l] + V[r] < K) {
            answer++;
//            std::cerr << l << " " << r << "\n";
//            std::cerr << "removing " << V[l] << " " << V[r] << " ";
            MS.erase({V[l], l});
            MS.erase({V[r], r});
            if (!MS.empty()) {
//                std::cerr << "and " << MS.rbegin()->first << "\n";
                MS.erase(MS.find(*MS.rbegin()));
            } else {
                break;
            }
            r--;
        }
    }

    while (MS.size()  > 1 && MS.begin()->first < K) {
        MS.erase(MS.find(*MS.begin()));
        MS.erase(MS.find(*MS.rbegin()));
        answer++;
    }
    answer += MS.size();

    std::cout << answer - 1 << "\n";
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int T;
    std::cin >> T;
    for (int i = 0; i < T; i++) {
        solve();
    }

    return 0;
}