#include <bits/stdc++.h>
using namespace std;
#define int long long


int n,c;
int *a,*b;
int solve()
{
    cin>>n>>c;
    a = new int[n];
    b = new int[n-1];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        cin>>b[i];
    }
    vector<vector<int>> v; 
    v.resize(n,vector<int>(2));
    v[0][0] = 0;
    v[0][1] = 0;
    int lvl = 0;
    int money = 0;
    int day = 0;
    for(int j = 0;j<n-1;j++)
    {
        int rm = b[j] - money;
        int rd;
        if(rm > 0)
        {
            if(rm%a[lvl] == 0) rd = rm/a[lvl];
            else rd = 1 + (rm/a[lvl]);
            day += rd;
            money += (rd*a[lvl]);
        }
        money -= b[j];
        day++;
        lvl++;
        v[lvl][0] = day;
        v[lvl][1] = money;
    }
    int mn;
    if(c%a[0] == 0) mn = c/a[0];
    else mn = 1 + (c/a[0]);
    for(int i=1;i<n;i++)
    {
        int rd,rm = c-v[i][1];
        if(rm <= 0) rd = v[i][0];
        else
        {
            if(rm%a[i] == 0) rd = rm/a[i];
            else rd = 1 + (rm/a[i]);
            rd += v[i][0];
        } 
        if(rd<mn) mn = rd;
    }
    return mn;
}
int32_t main()
{
    int no_loop,loop_;
    cin>>loop_;
    for(no_loop = 1; no_loop<=loop_;no_loop++)
    {
        int ans_ = solve();
        cout<<ans_<<endl;
    }
    return 0;
}
