//#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") //#pragma GCC optimize("unroll-loops") #include #define N 100005 #define inf 2147483647 #define LL long long using namespace std; int T,n,pos[N],a[N];LL m,S[N],pre[N]; struct FastIO{ static const int S=1048576; char buf[S],*L,*R;int stk[20],Top;~FastIO(){clear();} inline char nc(){return L==R&&(R=(L=buf)+fread(buf,1,S,stdin),L==R)?EOF:*L++;}inline void clear(){fwrite(buf,1,Top,stdout);Top=0;} inline void pc(char ch){Top==S&&(clear(),0);buf[Top++]=ch;}inline void endl(){pc('\n');} FastIO& operator >> (char&ch){while(ch=nc(),ch==' '||ch=='\n');return *this;} templateFastIO& operator >> (T&ret){ ret=0;int f=1;char ch=nc();while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=nc();} while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=nc();}ret*=f;return *this; } FastIO& operator >> (char* s){int Len=0;char ch=nc();while(ch!='\n'){*(s+Len)=ch;Len++;ch=nc();}} templateFastIO& operator << (T x){ if(x<0){pc('-');x=-x;}do{stk[++stk[0]]=x%10;x/=10;}while(x); while(stk[0]) pc('0'+stk[stk[0]--]);return *this; } FastIO& operator << (char ch){pc(ch);return *this;} FastIO& operator << (string str){int Len=str.size()-1;for(stk[0]=0;Len>=0;Len--) stk[++stk[0]]=str[Len];while(stk[0]) pc(stk[stk[0]--]);return *this;} }fin,fout; int main(){ // freopen("data.in","r",stdin); // freopen("jxc.out","w",stdout); fin>>T;while(T--){ fin>>n>>m;for(register int i=1;i<=n;i++) fin>>a[i],S[i]=S[i-1]+a[i],pre[i]=max(pre[i-1],S[i]);bool flg=0;int tot=0; LL now=0;for(register int i=1;i<=n;i++){now+=a[i];if(now<0) now=0,pos[++tot]=i;if(now>=m){flg=1,puts("1");break;}} if(flg) continue;if(!now){puts("-1");continue;} for(register int i=1;i<=tot;i++){if(now+S[pos[i]]<=0){if(now+pre[pos[i]-1]>=m) puts("2");else puts("-1");flg=1;break;}}if(flg) continue; if(now+pre[n]>=m) puts("2");else cout<<2+(LL)ceil(1.0*(m-now-pre[n])/S[n])<<'\n'; // LL tim=0;if(X+max(suf[pos[i]+1],pre[pos[i]-1])>=m) tim=1;else tim=(LL)ceil(1.0*(m-X-max(suf[pos[i]+1],pre[pos[i]-1]))/now)+1; // if(tim<=max((LL)ceil(1.0*(abs(S[i])-X)/now),0ll)){flg=1,cout<=m) cout<