/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define in insert
#define rev reverse
#define all(x) (x).begin(),(x).end()
#define all2(x) (x).rbegin(),(x).rend()
#define sz(v) (int)v.size()
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define vi vector<int>
#define vii vector<pair<int, int > >
#define vl vector<ll>
#define fi first
#define se second
#define l_b lower_bound
#define u_b upper_bound
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define tail cout << '\n'

using namespace std;

template<class T> void read(T &x) { cin >> x; }
template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }
template<class T> void print1(const T &x) { cout << x << '\n'; }
template<class T, class ...U> void print1(const T &x, const U& ... u) { print1(x); print1(u...); }
template<class T> void print2(const T &x) { cout << x << ' '; }
template<class T, class ...U> void print2(const T &x, const U& ... u) { print2(x); print2(u...); }

int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
//int n, m;

bool valid (int x, int y) {
    //return (x >= 0 && x < n && y >= 0 && y < m);
}

bool vis[55][55];

const int N = 1005, mod = 1e9 + 7, M = 5e5 + 5;
const ll inf = 9e18;
int cs = 1;

void solve() {
    ll n, c;
    read(n, c);
    vi a(n);
    take;
    vi b(n - 1);
    for(auto &it : b)
        cin >> it;
    ll hi = c, low = 1, mid, ans;
    while(hi >= low) {
        mid = (hi + low) >> 1;
        ll day = mid;
        ll tk = 0;
        bool ok = 0;
        for(int i = 0; i < n; i++) {
            if(tk + a[i] * day >= c) {
                ok = 1; break;
            }
            else {
                if(i == n - 1) {
                    if(tk + a[i] * day >= c) {
                        ok = 1;
                        break;
                    }
                }
                else {
                    if(tk >= b[i]) {
                        tk -= b[i];
                        day--;
                    }
                    else {
                        ll k = b[i] - tk;
                        ll l = k / a[i] + (k % a[i] != 0);
                        day -= l + 1;
                        tk += l * a[i];
                        tk -= b[i];
                    }
                }
            }
            //if(mid == 6) print1(day);
            if(day < 0) {
                break;
            }
        }
        if(ok) {
            ans = mid;
            hi = mid - 1;
        }
        else {
            low = mid + 1;
        }
    }
    cout << ans << '\n';
}

int main() {
    ios;
    int tc;
    read(tc);
    while(tc--)
    solve();
    return 0;
}
