#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ms(v,x) memset(v,x,sizeof(v))
#define td(v) v.begin(),v.end()
#define rtd(v) v.rbegin(),v.rend()
#define ff first
#define ss second
using namespace std;

const ll INF=1ll<<60;
const ll mod=1000000007;
const long double PI=acosl(-1);

ll binpow(ll a, ll b) {
	if (b == 0)
		return 1;
	ll res = binpow(a, b / 2);
	if (b % 2)
		return res * res * a;
	else
		return res * res;
}

void solve(){
	ll n,m,i,j,days=0,gat=0,resp=INF;
	cin>>n>>m;
	vector<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];
	}
	for(i=0;i<n-1;i++){
		resp=min(resp,max((m-gat+a[i]-1)/a[i],0ll)+days);
		days+=max((b[i]-gat+a[i]-1)/a[i],0ll)+1;
		gat+=max(((b[i]-gat+a[i]-1)/a[i]),0ll)*a[i]-b[i];
	}
	resp=min(resp,max((m-gat+a[n-1]-1)/a[n-1],0ll)+days);
	cout<<resp<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	// freopen("lcm.in", "r", stdin);
	// freopen("hidden.out", "w", stdout);
	ll t=1;
	cin>>t;
	// ll aux =t;
	while(t--){
		// cout<<"Case #"<<aux-t<<": ";
		solve();
	}
}