#include #include using namespace std; typedef long long ll; const int MOD = 998244353; const int MAXN = 100005; ll ksm(ll a,ll b) { ll t = 1; while(b){ if(b&1) t = t*a%MOD; a = a*a%MOD; b >>= 1; } return t%MOD; } ll a[MAXN]; /* 2 4 10 1 -2 3 -1 */ ll b[5][MAXN]; int main() { int t; scanf("%d",&t); while(t--) { ll n,m; scanf("%lld %lld",&n,&m); for(int i = 1;i <= n;i++) scanf("%lld",&a[i]); ll x = 0; int cnt = 0; while(x < m && cnt < 5) { // printf("---------%d-------------\n",cnt); for(int i = 1;i <= n && x < m;i++) { x += a[i]; if(x < 0) x = 0; // printf("%d%c",x," \n"[i == n]); b[cnt][i] = x; } // printf("---------%d-------------\n",cnt); cnt += 1; } // printf("%d\n",cnt); // continue; if(x >= m) printf("%d\n",cnt); else { int f = 0; for(int i = 1;i <= n;i++) if(b[3][i] != b[4][i]) { f = 1; break; } if(!f) puts("-1"); else { ll Max = b[4][1]; for(int i = 1;i <= n;i++) Max = max(Max,b[4][i]); ll cha = Max - b[4][1]; ll inv = b[4][n] - b[3][n]; ll be = b[0][n]; // ll ans = (m - be)/inv; ll cs = (m - be - a[1] - cha)/inv - 5; ll xx = cs*inv + be; while(xx < m)// && cnt < 3) { // printf("---------%d-------------\n",cnt); for(int i = 1;i <= n && xx < m;i++) { xx += a[i]; if(x < 0) x = 0; // printf("%d%c",x," \n"[i == n]); // b[cnt][i] = x; } // printf("---------%d-------------\n",cnt); cs += 1; } printf("%lld\n",cs + 1); } } } return 0; }