#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<map>
#include<string>
#include<unordered_map>
#include<vector>
#include<cmath>
#include<set>
#include<cstdio>
#include <cstdlib>
#include <ctime>
#include <cstdlib>
#include <numeric>
#include <queue>
using namespace std;

typedef long long ll;
typedef long double ldd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef set<int> si;

#define int long long
#define pb push_back
//#define mp make_pair
#define X first
#define Y second
#define fi first
#define se second
#define fr first
#define sc second
#define For(i, a, b) for (int i = a; i < b;i++)
#define forn(i, a) for (int i = 0;i < a;i++)
#define ford(i, a, b) for (int i = b - 1;i >= a;i--)
#define forr(x, arr) for(auto &x: arr)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define endl "\n"

#define mod ((ll)1000000007)
#define inf ((ll)100000000000)

constexpr ll N= 500005;

int m;
int a[N],b[N];

void solve(){
    int n,c=0;
    cin>>n>>m;
    forn(i,n)
        cin>>a[i];
    forn(i,n-1)
        cin>>b[i];
    int o=0,mx=inf;int k=0;
    forn(i,n){
        //cout<<o<<" ";
        if(o<m)
            if(k+(m-o+a[i]-1)/a[i]<mx)
                mx=k+(m-o+a[i]-1)/a[i];
        //cout<<"---"<<k+(m-o+a[i]-1)/a[i]<<endl;
        if(i<n-1){
            if(o<b[i]){
                int y=(b[i]-o+a[i]-1)/a[i];
                o+=y*a[i];
                k+=y;
            }
            k++;
            o-=b[i];
        }
    }
    cout<<mx<<endl;
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cout.precision(12);
    cout.fixed;
    int t=1,a,m,b;
    cin>>t;
    while(t--){
        solve();
    }
}