#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <iostream>
using namespace std;
#define f(x,y,z) for(int x=y;x<z;++x)
int t, n, c, rem, cur, ans, bar, a[200000], b[200000];
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    for(cin >> t; t--;) {
        cin >> n >> c;
        f(i,0,n) cin >> a[i];
        f(i,0,n-1) cin >> b[i];
        rem = cur = 0, ans = 1e9+7;
        f(i,0,n) {
            ans = min(ans, cur+max(0, c-rem+a[i]-1)/a[i]);
            bar = max(0, b[i]-rem+a[i]-1)/a[i];
            cur += bar+1, rem += a[i]*bar-b[i];
            if(cur >= c) break;
        }
        cout << ans << '\n';
    }
}