#include using namespace std; typedef long long ll; const ll maxn = 100000 + 10; ll a[maxn]; ll sum[maxn]; ll all[maxn]; int main() { int T; scanf("%d", &T); while(T--) { ll n, m; ll max_ = 0, final_ = 0, sub_ = 0; ll max_all = -1e9 - 10; scanf("%lld%lld", &n, &m); memset(a, 0, sizeof(a)); memset(sum, 0, sizeof(sum)); memset(all, 0, sizeof(all)); for(ll i=0; i max_) { max_ = sum[0]; } all[0] = a[0]; if(all[0] > max_all) { max_all = all[0]; } for(ll i=1; i max_all) { max_all = all[i]; } if(all[i] < 0) { if(all[i] * (-1) > sub_) { sub_ = all[i] * (-1); } } sum[i] = sum[i-1] + a[i]; if(sum[i] < 0) sum[i] = 0; if(sum[i] > max_) { max_ = sum[i]; } } final_ = sum[n-1]; /* //max_all 最大 //max_ 最大 // final_ 一轮终止 // sub_ 回撤 cout << max_all << endl; cout << max_ << endl; cout << final_ << endl; cout << sub_ << endl; */ if(final_ == 0) { if(max_ >= m) { cout << "1" << endl; } else { cout << "-1" << endl; } } else if(final_ > 0) { if(final_ > sub_) { if(max_ >= m) { cout << "1" << endl; } else { if(final_ + max_all >= m) { cout << "2" << endl; } else { ll ans = 0; m = m - max_all; m = m - final_; ll num = m / (final_ - sub_); ll k =m % (final_ - sub_); ans = 2 + num; if(k > 0) ans++; cout << ans << endl; } } } else if(final_ <= sub_) { if(max_ >= m) { cout << "1" << endl; } else { if(final_ + max_all >= m) { cout << "2" << endl; } else if(final_ + max_all < m) { cout << "-1" << endl; } } } } } return 0; } /* 5 5 1 -3 3 2 -2 */