#include using namespace std; const int N = 100000 + 9; int a[N]; void solve() { int n; long long m; scanf("%d %lld", &n, &m); for (int i = 1; i <= n; ++i) { scanf("%d", a + i); } long long maxv = 0, sum = 0; for (int i = 1; i <= n; ++i) { sum += a[i]; maxv = max(maxv, sum); } long long ans = 0; long long x = 0; long long _x = 0; while (true) { int cnt = 0; bool f = false; for (int i = 1; i <= n; ++i) { x += a[i]; if (x < 0) { x = 0; ++cnt; } else if (x >= m) { f = true; break; } } ++ans; if (f) break; if (x == _x) { ans = -1; break; } if (cnt) { _x = x; } else { if (x + maxv >= m) { ++ans; } else { ans += (m - x - maxv - 1) / (x - _x) + 2; } break; } } printf("%lld\n", ans); } int main() { int T; scanf("%d", &T); while (T--) solve(); return 0; }