#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1e9+7
#define inf 1e18
#define N 1000043
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
#define pll pair<ll,ll>
#define int ll
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    test{
        int n,c;
        cin >> n >> c;
        vector<int>vec(n),arr(n,1);
        loop(0,n) cin >> vec[i];
        loop(1,n) cin >> arr[i-1];
        int ans=c;
        int las=0,curr=0;
        for(int i=0;i<n;i++){
            int x=(c-las);
            if(x<0)   x=0;
            int y=x/vec[i];
            if(x%vec[i]!=0)   y++;
            ans=min(ans,curr+y);
            x=(arr[i]-las);
            if(x<0) x=0;
            y=x/vec[i];
            if(x%vec[i]!=0) y++;
            las+=vec[i]*y-arr[i];
            curr+=y+1;
        }
        cout << ans << endl;
    }
}

