#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define ff first
#define ss second
#define read freopen("in.c", "r", stdin)
#define write freopen("out.c", "w", stdout)
#define dbg(a) cout << "Line " << __LINE__ << ": " << #a << " => " << a << endl

typedef long long ll;

const int mx = 10000005;
const ll mod = 100000007;

int main() {
       int t;
       cin >> t;
       while (t--) {
              int n, c;
              cin >> n >> c;
              int a[5 + n], b[5 + n];
              for (int i = 1; i <= n; ++i) cin >> a[i];
              for (int i = 1; i < n; ++i) cin >> b[i];
              ll mn = 1e10, cur = 0, d = 0;

              for (int i = 1; i <= n; ++i) {
                     ll need = c - cur;
                     ll day = (max(0LL, need) + a[i] - 1) / a[i];
                     mn = min(mn, day + d);
                     //cout<<cur<<" "<<day+d<<" "<<i<<endl;
                     if (i < n) {
                            if (cur < b[i]) {
                                   int t = (b[i] - cur + a[i] - 1) / a[i];
                                   d += t + 1;
                                   cur += (t * a[i]);
                                   cur -= b[i];
                            } else {
                                   cur -= b[i];
                                   d++;
                            }
                     }
              }
              cout << mn << endl;
       }
}
