#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;



int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll n,c;
        cin>>n>>c;
        vector<ll> a(n), b(n);
        for(ll i=0;i<n;i++)
            cin>>a[i];
        for(ll i=0;i<n-1;i++)
            cin>>b[i];
        ll ans=mod*mod, cur=0, day=0;
        for(ll i=0;i<n;i++){
            ans=min(ans, day + max(0ll,(c-cur+a[i]-1)/a[i]) );
            if(cur>=b[i]){
                cur-=b[i];
                day++;
                continue;
            }
            ll need = b[i]-cur;
            ll d = (need+a[i]-1)/a[i];
            cur = d*a[i] - need;
            day += d + 1;
        }
        cout<<ans<<"\n";
    }

 
    cerr<<"\n\nTIME: "<<(long double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}