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

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        int n, k;
        scanf("%d%d", &n, &k);
        vector<int> v(n);
        for (auto& i : v ) scanf("%d", &i);
        sort(v.begin(), v.end());
        int low = 0, high = n / 2, mid;
        while (low != high) {
            mid = (low + high + 1) / 2;
            bool ok = 1;
            for (int i=0; i<mid; i++) ok = ok && (v[i] + v[mid * 2 - 1 - i] < k);
            if (ok) low = mid;
            else high = mid - 1;
        }
        int a = low, b = 0, c = 0, ans = -1;
        for (int i=low*2; i<n; i++) {
            if (v[i] < k) b++;
            else c++;
        }
        //printf("%d %d %d\n", a, b, c);
        while (a > 0 && c > 0) {
            a--;
            c--;
            ans++;
        }
        while (b > 0 && c > 0) {
            b--;
            c--;
            ans++;
        }
        ans += c;
        while (a > 0) {
            while (a > 0 && b > 0) {
                a--;
                b--;
                ans++;
            }
            if (a > 0) {
                a--;
                b += 2;
            }
        }
        ans += (b + 1) / 2;
        printf("%d\n", ans);
    }
}