#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define int ll

using namespace std;

const int N = 3e5 + 3;

int n, k;
int a[N];
int cnt[30005];
set<pair<int, int> > st;


void solve() {
    cin >> n >> k;
    st.clear();
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
        st.insert(mp(a[i], i));
    }

    int ans = 0;
    vector<pair<int, int> > anss;

    while(st.size() > 0) {
        auto it = st.lower_bound(mp(k, 0));
        if(it != st.begin()) {
            it--;
            int x = it->ff;
            int ps = it->ss;

            st.erase(it);
            auto it1 = st.lower_bound(mp(k - x, 0));
            if(it1 != st.begin()) {
                it1--;
                st.erase(it1);
                if(st.size() > 0)
                    st.erase(st.find(*st.rbegin()));
                ans++;
            } else {
                if(st.size() > 0) {
                    if(st.rbegin()->ff >= x) {
                        st.erase(st.find(*st.rbegin()));
                        ans++;
                    } else {
                        auto it2 = st.lower_bound(mp(k, 0));
                        if(it2 != st.begin()) {
                            it2--;
                            int y = it2->ff;
                            st.erase(it2);
                            auto it3 = st.lower_bound(mp(k - y, 0));
                            if(it3 != st.begin()) {
                                it3--;
                                st.erase(it3);
                            }
                        }
                        ans++;
                    }
                } else {
                    ans++;
                }
            }

        } else {
            st.erase(it);
            ans++;
        }
    }

    cout << ans - 1 << endl;
}

main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
}

/*
1
3 10
2 6 8

1
4 4
2 3 4 4

5
8 25
4 5 18 3 17 17 18 14
7 21
20 14 1 4 20 8 4
8 1
20 5 9 4 14 12 2 20
8 37
2 13 13 11 12 19 16 18
4 38
15 3 14 7

1
7 21
20 14 1 4 20 8 4

1
8 25
4 5 18 3 17 17 18 14

5
8 25
4 5 18 3 17 17 18 14
7 21
20 14 1 4 20 8 4
8 1
20 5 9 4 14 12 2 20
8 37
2 13 13 11 12 19 16 18
4 38
15 3 14 7

1
8 1
20 5 9 4 14 12 2 20

*/