#include<bits/stdc++.h>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ll long long int
#define fi first
#define ss second
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define inf 1000000000
#define endl '\n'

using namespace std;

/*
ll fact[200008]={0}, invfact[200008]={0};
ll power(ll a, ll b)
{
	ll ans = 1;
	while (b)
	{
		if (b & 1)
		ans = (ans * a) % mod;
		
		b /= 2;
		a = (a * a) % mod;
	}
	return ans;
}

ll modinv(ll k)
{
	return power(k, mod - 2ll);
}
 
void precompute()
{
	fact[0] = fact[1] = 1;
	for (ll i = 2; i < 200005; i++)
	{
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}
	invfact[200004] = modinv(fact[200004]);
	for (ll i = 200003; i >= 0; i--)
	{
		invfact[i] = ((invfact[i + 1]%mod) * ((i + 1)%mod));
		invfact[i] %= mod;
	}
}
 
ll ncr(ll x, ll y)
{
    if(x<y)
    return 0;
	ll num = fact[x];
	num=num%mod;
	num = ((num%mod)*(invfact[y]%mod))%mod;
	num %= mod;
	num = ((num%mod)*(invfact[x-y]%mod))%mod;
	num %= mod;
	return num;
}
*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin>>t;
    
    //precompute();
    
    while(t--)
    {
        int n;ll w;
        cin>>n>>w;
        
        ll a[n],cnt=0,sum=0,fg=0,rem;
        for(int i=0;i<n;i++)
        cin>>a[i];
        
        
        int f[25]={0};
        for(int i=0;i<25;i++)
        f[i]=0;
        
        for(int i=0;i<n;i++)
        {
            ll x=(ll)(log2(a[i]));
            f[x]++;
        }
        
        while(1)
        {
            rem=w;
            fg=0;
            
            for(ll i=22;i>=0;i--)
            {
                while(f[i]>0)
                {
                    ll p=pow(2,i);
                    if(p <= rem)
                    {
                        rem=rem-(p);
                        f[i]--;
                        fg=1;
                    }
                    else
                    break;
                }
            }
            
            if(fg==1)
            cnt++;
            else
            break;
        }
        
        cout<<cnt;
        cout<<endl;
    }
    return 0;
}