#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using pii = pair<int, int>;

const int N = 2e5+10;
LL t, n, c, now, day, ans, td, a[N], b[N];

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> t;
    while (t--) {
        cin >> n >> c;
        for (int i=0; i<n; i++) cin >> a[i];
        for (int i=0; i<n-1; i++) cin >> b[i];
        now = 0, day = 0, ans = INT_MAX;
        for (int i=0; i<n; i++) {
            td = (c-now)/a[i]+((c-now)%a[i]?1:0);
            ans = min(ans, day+td);
            if (i+1<n) {
                if (b[i] > now) {
                    td = (b[i]-now)/a[i]+((b[i]-now)%a[i]?1:0);
                    now += td*a[i];
                    day += td;
                }
                now -= b[i];
                day++;
            }
        }
        cout << ans << endl; 
    }

}