// #pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i, l, r) for(int i=l; i<=r; i++) #define dow(i, l, r) for(int i=l; i>=r; i--) #define fi first #define se second #define pb push_back #define mp make_pair #define clr(x, c) memset(x,c,sizeof(x)) typedef long long ll; typedef unsigned long long ull; typedef pair Pii; inline int read() { int x=0,f=0; char ch=getchar(); while (ch<'0' || '9'n) // struct edge{int y; edge *n;} e[maxm], *fir[maxn], *pt=e; // void AddE(int x, int y){pt->y=y, pt->n=fir[x], fir[x]=pt++;} // =========================== 快速幂 // inline int pow(int x, int t) { // int g = 1; // while (t) { // if (t&1) g = 1LL*g*x%Q; // x = 1LL*x*x%Q; // t >>= 1; // } // return g; // } // ====================================================== 主程序 #define maxn 100000 int a[maxn]; int n; ll m; int main() { int T = read(); while (T--) { scanf("%d%lld", &n, &m); rep(i, 1, n) a[i] = read(); ll x = 0, y = 0, mn = 0, mx = 0, ans = 0, st = m; rep(i, 1, n) { x += a[i], y += a[i]; if (y < mn) mn = y; if (y > mx) mx = y; if (x < 0) x = 0; if (x >= m) {ans = 1; break;} if (m - x - mn < st) st = m - x - mn; } if (ans) {puts("1"); continue;} if (st <= x) {puts("2"); continue;} if (mn < 0) { if (x + mn <= 0) {puts("-1"); continue;} } if (y < 0) {puts("-1"); continue;} ans = 2; ans += (st-x) / y; x += (st-x)/y*y; while (x < st) x += y, ans += 1; printf("%lld\n", ans); } return 0; }