#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iomanip>
#include <climits>
#define ll long long
#define mod 1000000007

// templates
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define po(x,y)   fixed<<setprecision(y)<<x
#define ss(s) scanf(" %[^\n]%*c", s)
#define sc(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define ps(s) printf("%s\n",s)
#define pr(n) printf("%d\n",n)
#define pl(n) printf("%lld\n",n)
#define prs(n) printf("%d ",n)
#define pls(n) printf("%lld ",n)
using namespace std;

const ll inf = (ll)1e15 + 10;
const int N = (int)1e6 + 10;

void solve()
{
	ll n, w;
	sl(n), sl(w);
	std::vector<ll>a(n);
	map<ll, ll>mp, layer;
	for (int i = 0; i < n; ++i)
	{
		sl(a[i]);
		mp[a[i]]++;
	}
	int ans = 0;
	while (n > 0) {
		ll curr = w;
		for (int i = 21; i >= 0; i--) {
			ll p = 1 << i;
			while (mp[p] > 0 && curr >= p) {
				n--;
				mp[p]--;
				curr -= p;
			}
		}
		ans++;
	}
	pr(ans);

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	sc(t);
	while (t--) {
		solve();
	}
	cerr << (float)clock() / CLOCKS_PER_SEC * 1000 << " ms" << endl;
	return 0;

}