#include <bits/stdc++.h>

#define forab(i, a, b) for (long long i = a; i < b; i++)
#define for0(i, n) for(int  i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i < n; i++)
#define pb push_back
#define mp make_pair

#define en '\n'

#define PI 3.14159265
#define EPS 1e-9

#define vec vector
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ld, int> pli;

typedef map<int, int> mii;
typedef map<ll, ll> mll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;


void solve(){
    ll n, c;
    cin >> n >> c;
    vll sel(n);
    vll cost(n-1);
    for0(i, n){
        cin >> sel[i];
    }
    for0(i, n-1){
        cin >> cost[i];
    }
    vll dp(n, 0);
    vll ost(n, 0);
    vll day(n, 0);
    for0(i, n-1){
        ll calc = ost[i];
        ll day_work = 0;
        if (calc<cost[i]){
            day_work = (cost[i]-calc+sel[i]-1)/sel[i];
        }
        calc += sel[i]*day_work;
        day[i+1] = day[i] + day_work + 1;
        ost[i+1] = calc - cost[i];
    }
//    for0(i, n){
//        cout << day[i] << " ";
//    }
//    cout << en;
//
//    for0(i, n){
//        cout << ost[i] << " ";
//    }
    ll ans = 1e18;
    for0(i, n){
        ll help = day[i];
        help += (c-ost[i]+sel[i]-1)/sel[i];
        ans = min(ans, help);
    }
    cout << ans;
    cout << en;
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

#ifndef DEBUG
    //freopen("kingdom.in", "r", stdin);
    //freopen("kingdom.out", "w", stdout);
#endif

    int tst = 1;
    cin >> tst;
    while (tst--)
        solve();
}
