#include #define fo(i,a,b) for(int i=a;i<=b;++i) #define fod(i,a,b) for(int i=a;i>=b;--i) using namespace std; typedef long long LL; typedef pair pii; const int N=100500,INF=1e9+7; int read(int &n) { bool q=0;n=0;char ch=' '; for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar()); if(ch=='-')ch=getchar(),q=1; for(;ch>='0'&&ch<='9';ch=getchar())n=(n<<3)+(n<<1)+ch-48; return q?n=-n:n; } unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); mt19937 rand_num(seed); // 大随机数 int RD(int q){return rand_num()%q;} int n,m,ans; int a[N]; LL K; LL doit(LL nw) { fo(i,1,n) { nw=max(0ll,nw+a[i]); if(nw>=K)return -i; } return nw; } void init() { scanf("%d%lld",&n,&K); fo(i,1,n)read(a[i]); LL t=0,mx=0; fo(i,1,n)t=t+a[i],mx=max(mx,t); t=doit(0); if(t<0)return printf("%d\n", 1),void(); LL t1=doit(t); if(t1<0)return printf("%d\n", 2),void(); if(t==t1)return printf("-1\n"),void(); LL e=(K-t-mx)/(t1-t); LL nw=t+(t1-t)*e; LL ans=e+1; for(nw=doit(nw);nw>=0;++ans,nw=doit(nw)) { // printf(" %lld\n",nw); } printf("%lld\n",ans+1); } int main() { int q,w,_; read(_); while(_--) { init(); } return 0; }