#include<iostream>
#include<vector>
#include <chrono>
#include<map>
#include<cstring>
#include<queue>
#include<algorithm>
#include<set>
#include<cmath>
using namespace std;

#define     MX        200005
#define     mod       998244353
#define     ll        long long
#define     inf       1000000000
#define     ull       unsigned long long
#define     ld        long double
#define     mem(a,b)  memset(a,b,sizeof(a))
#define     fast()    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     F         first
#define     S         second
#define     mp        make_pair
#define     PI        acos(-1)
#define     Base      402653189
int   dx[]      ={+1,-1,0,0};
int   dy[]      ={0,0,+1,-1};

ll a[MX];
ll b[MX];

int main(){
    fast();
   //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int t;
    cin>>t;
    for(int tc=1;tc<=t;tc++){
        ll n,c;
        cin>>n>>c;
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=1;i<n;i++) cin>>b[i];

        ll days=INT_MAX;
        ll cur=0,hand=0;

        for(int i=1;i<=n;i++){
            //cout<<cur<<" "<<hand<<endl;
            if(cur>days) break;
            ll need=0;
            if(c>hand){
                need=(c-hand)/a[i];
                if((c-hand)%a[i]) ++need;
            }
            days=min(cur+need,days);

            ll next =0;
            if(i<n && b[i]>hand){
                next=(b[i]-hand)/a[i];
                if((b[i]-hand)%a[i]) {
                    ++next;
                    hand=a[i]-((b[i]-hand)%a[i]);
                }
                else hand=0;
            }
            else {
                hand-=b[i];
            }
            cur+=next+1;
        }

        cout<<days<<endl;
    }
























    return 0;
}
