#include<bits/stdc++.h>
using namespace std;

int main()
{
    int tc,o;
    scanf("%d",&tc);
    for(o=1;o<=tc;o++)
    {

        long long n,c,m,a,b,i,j,k,ans=LLONG_MAX,cr=0,day=0,fr,sc,tr,x,y,z,e,f,g;
        vector<long long>u,v;

        scanf("%lld %lld",&n,&c);

        for(i=1;i<=n;i++)
        {
            scanf("%lld",&a);  u.push_back(a);
        }

        for(i=1;i<=n-1;i++)
        {
            scanf("%lld",&a);  v.push_back(a);
        }

        for(i=1;i<=n;i++)
        {
            fr=u[i-1];

            x=c-cr; x=max(0LL,x);

            y=x/fr;  if(x%fr!=0)y++;

            ans=min(ans,y+day);

            //cout<<i<<"    "<<cr<<"      "<<day<<endl;


            if(i!=n)
            {
                sc=v[i-1];

                if(cr>=sc)
                {
                    day++; cr=cr-sc;
                }
                else
                {
                    z=sc-cr;

                    e=z/fr; if((z%fr)!=0){  e++;  }   f=e*fr;

                    cr=cr+f; day=day+e;

                    //cout<<"   "<<i<<"   "<<cr<<"   "<<day<<endl;


                    cr=cr-sc;  day++;


                }



            }



        }



        printf("%lld\n",ans);


        u.clear();  v.clear();






    }



    return 0;


}
