#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <assert.h>
#include <math.h>

using namespace std;

typedef long long ll;
#define FOR(i, n) for(int i=0; i<(n); i++)
#define nl cout << "\n";
#define pr(x) cout << (x) << "\n"
#define ff fflush(stdout);

int p[10000007];
set<int> primes;

void factors(long num)
{
	cout << num << " : ";
	for(long i=2; i<num; i++) {
		if (num%i==0) cout << i << ",";
	}
	cout << "\n";
}

void sieve()
{
	p[1] = p[2] = true;
	for(int i=3; i<10000007; i++) {
		if (i&1) p[i]=true;
		else p[i] = false;
	}


	for(int i=3; i<10000007; i++) {
		for(int j=i*i; j<10000007; j+=i) {
			p[j]=false;
		}
	}
	for(int i=2; i<10000007; i++) {
		if (p[i]) primes.insert(i);
	}
}

ll gcd(ll a, ll b)
{
	if (b==0) return a;

	return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
	return (a*b)/gcd(a,b);
}

void solve()
{
	int n;
	ll w;
	cin >> n >> w;
	ll a;
	vector<ll> b(20);
	FOR(i,n) b.push_back(0);
	for(int i=0; i<n; i++) {
		cin >> a;
		b[log2(a)]++;
	}

	int height=1;

	int total = n;
	ll space = 0;
	while(total>0) {
		for(int i=20; i>=0; i--) { // for all boxes starting from the biggest size
			while((b[i]>0) and ((space+(1L<<i))<=w)) {
				space += (1L<<i);
				total--;
				b[i]--;
			}
		}
		space = 0;
		height++;
	}
	cout << (height-1) << "\n";
}

int main() {

	int t;
	cin >> t;
	while(t--) {
		solve();
	}

	return 0;
}

