// In the name of Allah
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	ll t;
	cin>>t;
	while(t--){
		ll n,c;
		cin>>n>>c;
		vector<ll>a(n),b(n);
		for(ll i=0;i<n;i++)cin>>a[i];
		for(ll i=0;i<n-1;i++)cin>>b[i];
		ll s=0,r=0;
		vector<ll>stay(n),rem(n);
		for(ll i=0;i<n-1;i++){
			ll req=b[i]-r;
			if(req<=0){
				stay[i]=s+1;
				s=stay[i];
				r=r-b[i];
				rem[i]=r;
			}else{
				ll day=req/a[i];
				if(req%a[i]!=0)day++;
				stay[i]=s+day+1;
				s=stay[i];
				r=day*a[i]+r-b[i];
				rem[i]=r;
			}
		}
		
		ll ans=1e14;
		for(ll i=0;i<n;i++){
			ll day=0,money=0;
			if(i>0){
				day=stay[i-1];
				money=rem[i-1];
			}
			
			ll req=c-money;
			if(req>0){
				day+=req/a[i];
				if(req%a[i]!=0)day++;
			}
		//	cout<<i<<" "<<day<<" "<<money<<endl;
			ans=min(ans,day);
		}
		cout<<ans<<endl;
	}
	return 0;
}