#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3", "omit-frame-pointer","inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,fma,popcnt,abm,mmx,avx,avx2")

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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;
//const long long mod = 998244353;
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int mxN = 200010;

int main(int argc, char *argv[]) {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif

	srand(time(NULL));
	cout << fixed << setprecision(9);

	int t = 1;
//	int Case = 1;
	cin >> t;
//	t = 10000;
	while (t--) {
		int n;
		long long c;
		cin >> n >> c;
		vector<long long> a(n), b(n);
		for (int i = 0; i < n; i++)
			cin >> a[i];
		for (int i = 1; i < n; i++)
			cin >> b[i];
		long long res = INT_MAX;
		for (long long i = 0, cur = 0, carry = 0; i < n; i++) {
			res = min(res, cur + max(0ll, (c + a[i] - 1 - carry) / a[i]));
//			cerr << cur << ' ' << carry << ' ' << res << '\n';
			if (i + 1 < n) {
				long long need = b[i + 1] - carry;
				long long d = max(0ll, (need + a[i] - 1) / a[i]);
				cur += d + 1;
				carry = d * a[i] - need;
			}
		}
		cout << res << '\n';
	}
	return 0;
}

/* stuff you should look for:
 * overflow, array bounds
 * special cases (n=1?)
 * clear arrays
 * DON'T STICK TO ONE APPROACH
 * solve simpler or different variation
 * Solve DP using graph ( \_(-_-)_/ )
 */
