#include <bits/stdc++.h>
using ll = long long ;
using namespace std;
const int N = 2e5+5;

ll a[N],b[N],c;

int main(){
	int t;cin>>t;
	while (t--){
		ll ans=1e18;
		int n;scanf("%d%lld",&n,&c);
		for (int i=1;i<=n;i++){
			scanf("%lld",&a[i]);
		}
		for (int i=1;i<n;i++){
			scanf("%lld",&b[i]);
		}
		ll t1,t2; t1=t2=0;
		for (int i=1;i<=n;i++){
			ans=min(ans,t2+max(0ll,c-t1+a[i]-1)/a[i]);
			ll t=max(0ll,b[i]-t1+a[i]-1)/a[i];
			t2+=t+1;
			t1+=a[i]*t-b[i];
		}
		printf("%lld\n",ans);
	}

	return 0;
}