#include using namespace std; #define rep(i,s,t) for(int i=s;i<=t;++i) #define per(i,s,t) for(int i=s;i>t;--i) #define dd(x) cout<<#x<<" = "< pii; const int N=4e5+11; const int mod=998244353; ll a[N],b[N]; ll T,n,k,ans; ll m,x,y; int main(){ scanf("%lld",&T); while(T--){ scanf("%lld%lld",&n,&m); ll sum=0,mx=0; rep(i,1,n){ scanf("%lld",a+i); sum+=a[i]; mx=max(mx,sum); } x=0;ans=0; ++ans; rep(i,1,n){ x+=a[i]; if(x<0)x=0; if(x>=m){ printf("%d\n",ans); goto end; } } y=x; ++ans; rep(i,1,n){ x+=a[i]; if(x<0)x=0; if(x>=m){ printf("%d\n",ans); goto end; } } if(x<=y){ puts("-1"); } else{ ll p=(m-mx-x+x-y-1)/(x-y); printf("%lld\n",ans+1+p); } end:; } return 0; }