#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define endl "\n"

const ll M = 1e9 + 7;
const int mxx = 2e5 + 5;
const ll INF = 1e18 + 7;
/*__________________________________________________________________________________________________________________*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t;cin>>t;
    while(t--)
    {
        
        ll n,c;cin>>n>>c;
        ll a[n],b[n-1];

        for(int i=0;i<n;i++)cin>>a[i];
        for(int i=0;i<n-1;i++)cin>>b[i];
       
        ll prev=0;
        ll ans=INF;
        ll money=0;

        for(int i=0;i<n-1;i++)
        {
            ll x=(c-money+a[i]-1)/a[i];
            //if((c-money)%a[i])x++;

            ans=min(ans,prev+x);

            ll y=(b[i]-money+a[i]-1)/a[i];
            //if((b[i]-money)%a[i])y++;

            prev+=(y+1);
            money=money+y*a[i]-b[i];

        }
        
         ll x=(c-money+a[n-1]-1)/a[n-1];
        ans=min(ans,prev+x);

        cout<<ans<<endl;

    }       
}



