#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define en '\n'
#define sp ' '
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ar array
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
using namespace std;
//const ll mod = 998244353;
const ll mod = 1e9+7;
const int N = 1e7 + 2;
const int M = 1e6 + 2;
const int inf = 2e9;
const ll linf = 9e18;
ll ceil(ll a, ll b){
    return (a+b-1)/b;
}
void solve(){
    int n; ll c;
    cin >> n >> c;
    vector<ll>a(n),b(n);
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n-1;i++)cin >> b[i];
    ll ans = linf;
    ll t = 0;
    ll d = 0;
    for(int i=0;i<n;i++){
        smin(ans,ceil(c-t,a[i])+d);
        if(i+1<n){
            if(t>=b[i]){
                t-=b[i];
                d++;
            }
            else{
                d += (ceil(b[i]-t,a[i])) + 1;
                t += (a[i]*(ceil(b[i]-t,a[i])));
                t -= b[i];

            }
        }
    }
    cout << ans << en;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    int t;
    cin >> t;
    while(t--)solve();
    return 0;
}
