#include #define broken cerr << "running on " << __FUNCTION__ <<" "<< __LINE__ << endl #define x first #define y second #define mp make_pair #define sz(a) int((a).size()) #define par pair #define poly vector #define i64 long long #define u64 unsigned long long using namespace std; const int N = 1e5 + 10; int n, a[N]; i64 m; int check(i64 &x) { for(int i = 1; i <= n; i++) { x = max(0ll, x + a[i]); if(x >= m) return 1; } return 0; } i64 solve() { cin >> n >> m; i64 sum = 0, mx = 0; for(int i = 1; i <= n; i++) cin >> a[i], sum += a[i], mx = max(mx, sum); i64 x = 0; if(check(x)) return 1; i64 y = x; if(check(x)) return 2; i64 z = x; if(y >= z) return -1; i64 d = z - y; return 1 + (m - y - mx + d - 1) / d + 1; } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int T; cin >> T; while(T--) cout << solve() << endl; return 0; }