//Template Made By: Ojassvi Kumar
#include<bits/stdc++.h>
using namespace std;
 
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define fo(i,a,b) for(long long int i=a; i<b; i++)
#define endl "\n"
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define min3(a,b,c) min(min((a),(b)),(c))
#define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(V) V.begin(),V.end()
#define itv vector<long long int>::iterator
#define pll pair<long long int,long long int>
#define mp make_pair
#define itp vector<pair<long long int,long long int>>::iterator
#define sll set<long long int,greater<long long int>>
#define its set<long long int,greater<long long int>>::iterator
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
 
//const long double pi = 3.14159265358979323846264338;
//Template Ends
void printV(vector<ll> A){
    for(auto x:A)
        cout<<x<<" ";
    cout<<endl;
}
ll _ceil(ll A,ll B){
    if(A%B==0)
        return A/B;
    else
        return (A/B)+1;
}
int main(){
    ios
    #ifndef ONLINE_JUDGE
    freopen("INPUT.txt", "r", stdin);
    freopen("OUTPUT.txt", "w", stdout);
    #endif
    ll Tests=1;
    cin>>Tests;
    while(Tests--){
        ll N,C;
        cin>>N>>C;
        vector<ll> A(N),B(N-1);
        fo(i,0,N) cin>>A[i];
        fo(i,0,N-1) cin>>B[i];
        vector<ll> cost(N);
        cost[0]=0;
        vector<ll> minD(N),totD(N);
        minD[0]=0;
        totD[0]=_ceil(C,A[0]);
        fo(i,1,N){
            if(cost[i-1]>=B[i-1]){
                cost[i]=cost[i-1]-B[i-1];
                minD[i]=minD[i-1]+1;
            }
            else{
                cost[i]=_ceil((B[i-1]-cost[i-1]),A[i-1])*A[i-1]-B[i-1]+cost[i-1];
                minD[i]=minD[i-1]+_ceil((B[i-1]-cost[i-1]),A[i-1])+1;
            }
            totD[i]=_ceil((C-cost[i]),A[i]);
        }
        // printV(cost);
        // printV(minD);
        // printV(totD);
        vector<ll> ans(N);
        fo(i,0,N)
            ans[i]=minD[i]+totD[i];
        sort(all(ans));
        cout<<ans[0]<<endl;
    }
}