#include using namespace std; typedef long long ll; void debug_out(){ cerr << endl; } template void debug_out(Head H, Tail... T){ cerr << ' ' << H; debug_out(T...); } #ifdef local #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 55 #endif int main() { #ifdef local freopen("../in.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int T; cin >> T; while(T--){ int n; ll m; cin >> n >> m; vector s(n + 2), a(n + 2); ll ans1 = 0, mx = 0; ll ans = -1; for(int i = 1; i <= n; i++) cin >> a[i], s[i] = s[i - 1] + a[i], mx = max(mx, s[i]); for(int i = 1; i <= n; i++){ ans1 += a[i]; if(ans1 < 0) ans1 = 0; if(ans1 >= m){ ans = 1; break; } } if(ans != -1){ cout << ans << '\n'; continue; } ll ans2 = ans1; for(int i = 1; i <= n; i++){ ans2 += a[i]; if(ans2 < 0) ans2 = 0; if(ans2 >= m){ ans = 2; break; } } if(ans != -1){ cout << ans << '\n'; continue; } if(ans1 == ans2){ cout << -1 << '\n'; continue; } ll need = 2 + (m - ans2 - mx + s[n] - 1) / s[n] + 1; cout << need << '\n'; } return 0; }