#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 100010;
int a[N];
int n, k;
int check(int x) {
    if (n - x <= x) {
        return 1;
    }
    int j = 1;
    for (int i = n - x; i >= n - 2 * x + 1; i--) {
        if (i < j) {
            return 1;
        }
        if (j <= n - 2 * x && a[i] + a[j] < k) {
            j++;
        }
    }
    return (j > n - 2 * x);
}
void solve() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a+1, a+n+1);
    int at_least_k = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] >= k) {
            at_least_k++;
        }
    }
    int l = max(at_least_k, (n+2)/3);
    int r = n;
    while(l<r) {
        int mid = (l+r)/2;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid+1;
        }
    }
    printf("%d\n", l - 1);
}
int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        solve();
    }
    return 0;
}