#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int32_t main()
{
	IOS;

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

		int ans = 4e18, bal = 0, days = 0;
		for (int i = 1; i <= n; i++)
		{
			int cur = days +  max(0LL, (c - bal + a[i] - 1) / a[i]);
			ans = min(ans, cur);

			int newDays = max(0LL, (b[i] - bal + a[i] - 1) / a[i]);
			days += newDays + 1;
			bal += newDays * a[i] - b[i];
		}
		cout << ans << endl;

	}

	return 0;
}
