//#include <bits/stdc++.h>
//#include <ext/pb_ds/hash_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <random>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <ctime>

#define X first
#define Y second
#define ls rt<<1
#define rs rt<<1|1
#define getmid ((l+r)>>1)
#define PB push_back
#define EB emplace_back
#define lowbit(x) ((x)&-(x))
#define sz(a) ((int)a.size())
#define ALL(x) x.begin(),x.end()
#define mst(x,a) memset(x, a, sizeof(x))
using namespace std;
#ifdef LOCAL
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // LOCAL

//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;

const int N = 5e5 + 10;
const int M = 5e4 + 10;
const int maxn = 1e6 + 10;
const int mod = 998244353;
const db eps = 1e-15;
const db pi = acos(-1.0);
const ll seed = 131;

int n,w;
int c[30];

void work() {
    cin>>n>>w;
    mst(c, 0);
    for(int i=1; i<=n; i++) {
        int t; cin>>t;
        int cnt = 0;
        while(t > 1) {
            cnt++;
            t >>= 1;
        }
        c[cnt]++;
    }
    int ans = 0;
    while(n) {
        ans++;
        ll r = 0;
        for(int i=30; ~i; i--) {
            r <<= 1;
            if(w>>i&1) r |= 1;
            ll d = min(r, (ll)c[i]);
            c[i] -= d;
            n -= d;
            r -= d;
        }
    }
    cout<<ans<<'\n';
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif //LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t; cin>>t;
    while(t--) work();

    return 0;
}
