#include #define int long long using namespace std; const int maxn=1e5+100; const int mode=998244353; int read(){ int x=0,f=1;char ch=getchar(); while(!isdigit(ch)){ if(ch=='-') f=-1; ch=getchar(); } while(isdigit(ch)){ x=x*10+ch-'0'; ch=getchar(); } return x*f; } int t,n,m,si[maxn],sum[maxn],tot; signed main(){ t=read(); while(t--){ n=read(); m=read(); tot=0; int maxnum=-4325256464465543; bool juge=false; for(int i=1;i<=n;++i){ si[i]=read(); tot+=si[i]; maxnum=max(maxnum,tot); sum[i]=sum[i-1]+si[i]; if(sum[i]<0) sum[i]=0; if(sum[i]>=m) juge=true; } if(juge) cout<<1<<"\n"; else{ if(sum[n]<=0){ cout<<-1<<"\n"; continue; } int temp=sum[n]; bool juge=false; bool is=true; for(int i=1;i<=n;++i){ temp+=si[i]; if(temp>=m){ juge=true; break; } if(temp<=0){ is=false; break; } } if(juge){ cout<<2<<"\n"; continue; } if(!is||tot<=0){ cout<<-1<<"\n"; continue; } int ans=(m-sum[n]-maxnum)/tot; if(ans*tot+sum[n]+maxnum