#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 10;
ll n, t,c;
ll a[maxn], b[maxn];

int main ()
{
	cin >> t;
	while ( t-- )
	{
		cin >> n>>c;
		for ( int i = 1; i <= n; i++ )
			cin >> a[i];
		for ( int i = 1; i < n; i++ )
			cin >> b[i];

		ll ans = LLONG_MAX, use_day = 0, save_money = 0;
		for ( int i = 1; i <= n; i++ ) {
			ans = min ( ans, max(0ll,( c - save_money + a[i] - 1 )) / a[i] + use_day );
			ll new_day = max(0ll,( b[i] - save_money + a[i] - 1 ) )/ a[i];
			use_day += new_day+1;
			save_money = save_money + a[i] * new_day - b[i];
		}
		cout << ans << endl;
	}
}
