#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int INF = 0x3f3f3f3f;
ll a[maxn], b[maxn];
int dp[maxn];
inline ll read(){
	ll s = 0, w = 1;
	char c = getchar();
	while(c < '0' || c > '9'){
		if(c == '-')w = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9'){
		s = s * 10 + c - '0';
		c = getchar();
	}
	return s * w;
}
int main(){
	int t;
	cin >> t;
	while(t--){
		ll n, c;
		n = read(), c = read();
		for(int i = 1 ; i <= n ; i++)a[i] = read();
		for(int i = 1 ; i < n ; i++)b[i] = read();
	    ll ans = INF;
	    ll x = 0;
	    ll now = 0;
	    for(int i = 1 ; i <= n ; i++){
	    	ll k = c - x;
	    	if(k % a[i] == 0){
	    		ans = min(ans, (now + k / a[i])); 
			}
			else{
				ans = min(ans, (now + k / a[i] + 1));
			}
			now++;
			if(x < b[i]){
				now += (b[i] - x) / a[i];
	    		if((b[i] - x) % a[i]){
	    			now++;
				}
				if((b[i] - x) % a[i]){
					x = b[i] + a[i] - (b[i] - x) % a[i];
				}
				else x = b[i];
				x -= b[i];
			}
			else{
				x -= b[i];
			}
		}
		cout << ans << "\n";
	}
	
}