#include using namespace std; const int mod= 998244353; typedef long long ll; const ll inf = 1e18+100; const int maxn = 1e5+5; int a[maxn]; ll sum[maxn],sum2[maxn],sum3[maxn]; int main(){ int t; scanf("%d",&t); while(t--){ int n;ll m; scanf("%d%lld",&n,&m); ll ans=0; for(int i=1;i<=n;++i){ scanf("%d",&a[i]); sum[i]=(sum[i-1]+a[i]); if(sum[i]<0)sum[i]=0; else if(sum[i]>=m){ ans=1; } } if(ans)printf("%lld\n",ans); else{ for(int i=1;i<=n;++i){ if(i==1)sum2[1]=(sum[n]+a[i]); else sum2[i]=(sum2[i-1]+a[i]); if(sum2[i]<0)sum2[i]=0; else if(sum2[i]>=m){ ans=2; break; } if(sum2[i]==sum[i]){ ans=-1; break; } } if(ans)printf("%lld\n",ans); else{ for(int i=1;i<=n;++i){ if(i==1)sum3[1]=(sum2[n]+a[i]); else sum3[i]=(sum3[i-1]+a[i]); if(sum3[i]<0)sum3[i]=0; else if(sum3[i]>=m){ ans=3; break; } if(sum3[i]==sum2[i]){ ans=-1; break; } } if(ans){ printf("%lld\n",ans); }else{ ans=inf; for(int i=1;i<=n;++i){ // printf("%lld %lld\n",sum2[i],sum3[i]); ans=min(ans,(m-sum2[i]-1)/(sum3[i]-sum2[i])+3); } printf("%lld\n",ans); } } } } }