/*
    __  ___        __
   /  |/  /____   / /_ ____   _____ ____ _ _____
  / /|_/ // __ \ / __// __ \ / ___// __ `// ___/
 / /  / // /_/ // /_ / /_/ // /   / /_/ /(__  )
/_/  /_/ \____/ \__/ \____//_/    \__,_//____/
*/

#ifndef __AHA__HEADER
#define __AHA__HEADER

#include <bits/stdc++.h>
using namespace std;
#define g0 get<0>
#define g1 get<1>
#define g2 get<2>
#define ft first
#define sd second
#define sz(x) (i6) x.size()
#define psb(x) push_back(x)
#define ppb() pop_back()
#define bg(x) x.begin()
#define ed(x) x.end()
#define col(x) x.begin(), x.end()
#define srt(x) sort(x.begin(), x.end())
#define vec vector
#define deq deque
#define hmap unordered_map
#define pq priority_queue
#define fn function
#ifdef LOCAL
#define git stauDBG_MACRO_NO_WARNING
#include <dbg.h>
#define dbgt dbg(dbg::time())
#else
#define dbg(...)
#define dbgt
#endif
typedef string str;
typedef int32_t i3;
typedef int64_t i6;
typedef int64_t i64;
typedef uint32_t u3;
typedef uint64_t u6;
typedef long double d6;
typedef pair<i6, i6> p6;
typedef vec<i6> vi6;
typedef vec<p6> vp6;
typedef vec<bool> vb;
typedef vec<vi6> vv;
typedef deq<p6> dp6;
typedef deq<i6> di6;
typedef map<i6, i6> mi6;
typedef map<p6, i6> mp6;
typedef set<i6> si6;
typedef hmap<i6, i6> hi6;
typedef vv graph;
typedef vv matrix;

const d6 EPS = 1 / 1000000.0;
const i6 INF = INT64_MAX / 4;
const i6 NINF = -INF;
const i6 ZERO = 0;
const i6 ONE = 1;

namespace std {
template <typename T1, typename T2>
struct hash<pair<T1, T2>> {
  std::size_t operator()(const pair<T1, T2>& pair) const noexcept {
    return hash<T1>()(pair.first) ^ hash<T2>()(pair.second);
  }
};
}  // namespace std

template <typename T1, typename T2>
istream& operator>>(istream& stream, pair<T1, T2>& p) {
  stream >> p.ft;
  stream >> p.sd;
  return stream;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
  return stream << p.ft << " " << p.sd;
}

template <typename T>
istream& operator>>(istream& stream, vec<T>& v) {
  if (v.empty()) {
    u6 len;
    stream >> len;
    v.assign(len, T());
  }
  for (auto i = 0; i < sz(v); i++) {
    stream >> v[i];
  }
  return stream;
}

template <typename T>
ostream& operator<<(ostream& stream, const vec<T>& v) {
  if (!v.empty()) {
    stream << v[0];
  }
  for (auto i = 1; i < sz(v); i++) {
    stream << " " << v[i];
  }
  return stream;
}

#endif

map<p6, i6> dp;

i6 solve(i6 idx, i6 money, vi6& a, vi6& b, i6 c) {
  p6 key = {idx, money};
  auto fd = dp.find(key);
  if (fd != dp.end()) {
    return fd->sd;
  }
  if (idx == sz(a) - 1) {
    i6 left = c - money;
    i6 days = left / a[idx];
    if (left % a[idx] != 0) {
      days++;
    }
    dp[key] = days;
    return days;
  }

  i6 leftC = max(ZERO, c - money);
  i6 days1 = leftC / a[idx];
  if (leftC % a[idx] != 0) {
    days1++;
  }
  i6 o1 = days1;

  i6 left = max(ZERO, b[idx] - money);
  i6 days2 = left / a[idx];
  if (left % a[idx] != 0) {
    days2++;
  }
  money += a[idx] * days2;

  i6 o2 = days2 + 1 + solve(idx + 1, money - b[idx], a, b, c);
  dp[key] = min(o1, o2);
  return min(o1, o2);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifdef LOCAL
  ifstream cin{"input.txt"};
  ofstream cout{"output.txt"};
#endif
  i6 tc;
  cin >> tc;
  for (i6 tcn = 0; tcn < tc; tcn++) {
    i6 n, c;
    cin >> n >> c;
    vi6 a(n), b(n - 1);
    cin >> a;
    cin >> b;
    dp.clear();
    cout << solve(0, 0, a, b, c) << endl;
  }
  return 0;
}
