#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2ll);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cin>>t;
    while(t--){
        ll n,c;
        cin>>n>>c;
        ll a[n];
        ll b[n];
        for(ll i=0;i<n;i++){
            cin>>a[i];
        }
        for(ll i=0;i<n-1;i++){
            cin>>b[i];
        }
        ll cost=0;
        ll d=0;
        ll ans=c;
        for(int i=0;i<n;i++){
            ll d1=d+max(0ll,(c-cost+a[i]-1ll)/a[i]);
            ans=min(ans,d1);
            if(i<n-1){
                ll d2=max(0ll,(b[i]-cost+a[i]-1ll)/a[i]);
                d+=d2+1;
                cost+=d2*a[i];
                cost-=b[i];
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}