#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;
const int N=2e5+5;
const int inf=0x3f3f3f3f;
int a[N],b[N];
int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        int n,c;
        scanf("%d%d",&n,&c);
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(int i=1;i<n;i++)
            scanf("%d",&b[i]);
        int p=1;
        ll res=0,ans=c,cnt=0;
        while(p<=n){
            ll tmp=(c-res+a[p]-1)/a[p];
            ans=min(ans,cnt+tmp);
            if(p==n) break;
            if(res<b[p]){
                int x=(b[p]-res+a[p]-1)/a[p];
                cnt+=x;
                res+=1LL*x*a[p];
            }
            res-=b[p];
            cnt++,p++;
        }
        printf("%d\n",ans);
    }
    return 0;
}