#include using namespace std; typedef long long ll; typedef pair pi; typedef pair pl; typedef double db; #define ls(x) ((x)<<1) #define rs(x) ((x)<<1|1) #define low(x) ((x)&-(x)) #define all(x) x.begin(),x.end() #define mp make_pair #define X first #define Y second #ifdef _DEBUG const int N=1e3+10; #else const int N=1e6+10; #endif const ll mod=1e9+7; //const ll mod=998244353; inline ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);} inline ll q_pow(ll a,ll x){ll ans=1,tmp=a;while(x){if(x&1)(ans*=tmp)%=mod;(tmp*=tmp)%=mod;x>>=1;}return ans;} template inline void re(T &N){int f=1;char c;while((c=getchar())< '0'||c> '9')if(c=='-')f=-1;N=c-'0';while((c=getchar())>='0'&&c<='9')N=N*10+c-'0';N*=f;} templateinline void re(T&x,T_&...y){re(x),re(y...);} int n,t=1,st,en;ll m; int a[N]; ll solve() { ll now=0,ma=0,mi=0,del=0; ll ans=1; for(int i=1;i<=n;i++) { now+=a[i];del+=a[i]; if(now>=m)return ans; if(now< 0)now=0; mi=min(mi,del); ma=max(ma,del); } ans++; for(int i=1;i<=n;i++) { now+=a[i]; if(now>=m)return ans; if(now< 0)now=0; } if(del<=0)return -1; ll turn=max((m-ma-now+del-1)/del,0ll); ans+=turn+1; return ans; } int main() { #ifdef _DEBUG freopen("data.txt","r",stdin); #endif re(t); while(t--) { re(n,m); for(int i=1;i<=n;i++)re(a[i]); printf("%lld\n",solve()); } }