#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define M 1000000007
#define mod 998244353
#define pll pair<ll, ll>
#define f first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pb push_back
#define rb pop_back
#define prdb(x) cout << fixed << setprecision(10) << x;
#define speed1 ios_base ::sync_with_stdio(false);
#define speed2 cin.tie(NULL);
#define endl "\n"
/************
 * fill the array with desired value
    fill(all(vec), 1);    
    
 *fills the dsu parent array consecutively starting from desired value
    iota(all(parent), 0); 

 * sort the vector and then make all elements unique
    sort(all(vec)); 
    vec.resize(unique(all(vec)) - vec.begin());  

************/

// ll solve(ll n, ll days, ll a[], ll b[])
// {
//     ll i, j, k;
//     ll sum = 0;
//     ll hav = 0;

//     for (i = 0; i < n; i++)
//     {
//         if (i != n - 1 && hav < b[i])
//         {
//             ll diff = b[i] - hav;
//             ll dy = (diff + a[i] - 1) / a[i];
//             if (days >= dy + 1 && dy * a[i] - b[i] + (days - dy - 1) * a[i + 1] >= days * a[i])
//                 days -= (dy + 1), hav += dy * a[i] - b[i];
//             else
//             {
//                 hav += days * a[i];
//                 return hav;
//             }
//         }
//         else if (i != n - 1 && hav > b[i])
//         {
//             days--;
//             hav -= b[i];
//         }
//         else
//         {
//             hav += days * a[i];
//             return hav;
//         }
//         if (days == 0)
//             break;
//     }
//     return hav;
// }

int main()
{
    //#ifndef ONLINE_JUDGE
    //    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    //#endif
    speed1;
    speed2;

    ll t = 1;
    cin >> t;
    while (t--)
    {
        ll n, i, j, k, c;
        cin >> n >> c;
        ll a[n], b[n - 1];

        for (i = 0; i < n; i++)
            cin >> a[i];
        for (i = 0; i < n - 1; i++)
            cin >> b[i];

        ll ans = 1e10;
        ll hav = 0;
        ll days = 0;
        for (i = 0; i < n; i++)
        {
            ans = min(ans, days + (c - hav + a[i] - 1) / a[i]);
            if (i != n - 1 && hav < b[i])
            {
                ll diff = b[i] - hav;
                ll dy = (diff + a[i] - 1) / a[i];
                days += (dy + 1), hav += dy * a[i] - b[i];
            }
            else if (i != n - 1 && hav >= b[i])
                days++, hav -= b[i];
        }

        cout << ans << endl;
    }
}