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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);

    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> arr(n);
        for (auto &x : arr) {
            cin >> x;
        }
        sort(all(arr));

        auto good = [&](int K) {
            int l = 0, r = n - K - 1;
            if (r == -1) {
                return true;
            }
            if (arr[r] >= k) {
                return false;
            }
            int res = 0;
            while (l <= r) {
                ++res;
                if (arr[l] + arr[r] < k) {
                    ++l;
                    --r;
                }
                else {
                    --r; 
                }
            }
            return res <= K;
        };
        
        int L = (n + 2) / 3, R = n, res = -1;
        while (L <= R) {
            int M = (L + R) / 2;
            if (good(M)) {
                res = M;
                R = M - 1;
            }
            else {
                L = M + 1;
            }
        }
        cout << res - 1 << '\n';
    }


    return 0;
}