#include<bits/stdc++.h>

using namespace std;

#define ll long long
map<ll,ll>mp;
int main()
{
    int t;
    cin>>t;
    for(int q=1;q<=t;q++)
    {
        ll n,c;
        cin>>n>>c;
        ll a[n],b[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(int i=0;i<n-1;i++)
        {
            cin>>b[i];
        }
        ll mn=1e18;
        ll rem=c;
        ll day=0;
        for(int i=0;i<n;i++)
        {
            if(rem==0)
                break;
            ll cot=rem/a[i];
            if(rem%a[i]>0)
                cot++;
            mn=min(mn,cot+day);
            if(c-rem>=b[i])
            {
                rem+=b[i];
                day++;
                continue;
            }
            if(i==n-1)break;
            ll now=(b[i]-c+rem)/a[i];
            if((b[i]-c+rem)%a[i]>0)
                now++;

            rem=c-(now*a[i]-b[i]+c-rem);
            day+=now+1;


        }
        cout<<mn<<endl;
        //cout<<"Case #"<<q<<": "<<mx<<endl;

    }
}
