#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd1(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd1(b, a % b);
}
int main()
{
  int t=0;
  cin>>t;
  while(t--)
  {
      int n=0,w=0;
      cin>>n>>w;
      int hash[20];
      memset(hash,0,sizeof(hash));
      for(int i=0;i<n;i++)
      {
          int x=0;
          cin>>x;
          hash[(int)log2(x)]++;
      }
      int height=1;
      int space=w;
      for(int i=0;i<n;i++)
      {
          int largest=-1;
          for(int i=19;i>=0;i--)
          {
              if(hash[i] && (1<<i)<=space)
              {
                  largest=i;
                  break;
              }
          }
          if(largest==-1)
          {
              space=w;
              height++;
              for(int i=19;i>=0;i--)
              {
                  if(hash[i] && (1<<i)<=space)
                  {
                      largest=i;
                      break;
                  }
              }
              
          }
          space-=(1<<largest);
          hash[largest]-=1;
      }
      cout<<height<<endl;
  }
}