#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define rf(i, a, b) for (ll i = a; i >= b; i--)
typedef std::vector<long long> vi;
#define F first
#define S second
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(), a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
const ll INF = LLONG_MAX / 2;
const ll N = 2e5 + 1;
using namespace std;
void solve()
{
    ll n, c;
    cin >> n >> c;
    ll a[n], b[n];
    fr(i, 0, n)
    {
        cin >> a[i];
    }
    fr(i, 1, n)
            cin >>
        b[i];
    ll ans = INF, prevcoins = 0, prevdays = 0;
    fr(i, 0, n - 1)
    {
        if (c <= prevcoins)
            ans = min(prevdays, ans);
        ans = min(prevdays + (c - prevcoins + a[i] - 1) / a[i], ans);
        // cout << prevdays + (c - prevcoins + a[i] - 1) / a[i] << " ";
        if (prevcoins >= b[i + 1])
        {
            prevcoins = prevcoins - b[i + 1];
            prevdays++;
        }
        else
        {
            prevdays = prevdays + (b[i + 1] + a[i] - 1 - prevcoins) / a[i] + 1;
            prevcoins = ((b[i + 1] + a[i] - 1 - prevcoins) / a[i]) * a[i] + prevcoins - b[i + 1];
        }
        // cout << prevdays << " " << prevcoins << "\n";
    }
    ll i = n - 1;
    ans = min(prevdays + (c - prevcoins + a[i] - 1) / a[i], ans);
    // cout << "\n";
    cout << ans << "\n";
}
int main()
{
    fast;
    ll t = 1;
    std::cin >> t;
    while (t--)
    {
        solve();
    }
}