﻿#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t)
	{
		long long n, c, have = 0, day = 0, ans;
		cin >> n >> c;
		vector<long long> a(n), b(n - 1);
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		for (int i = 0; i < n - 1; i++)
		{
			cin >> b[i];
		}
		ans = (c + a[0] - 1) / a[0], day = (b[0] + a[0] - 1) / a[0] + 1, have = a[0] * (day - 1) - b[0];
		for (int i = 1; i < n - 1; i++)
		{
			ans = min(ans, day + (c - have + a[i] - 1) / a[i]);
			day += (b[i] - have + a[i] - 1) / a[i] + 1;
			have = (b[i] - have + a[i] - 1) / a[i] * a[i] - b[i] + have;
		}
		ans = min(ans, day + (c - have + a[n - 1] - 1) / a[n - 1]);
		cout << ans << endl;
		t--;
	}
}