#include <bits/stdc++.h>
using namespace std;
long long tt;
long long n, s;
void solve() {
  cin >> n >> s;
  long long nums_after = n / 2;
  long long ans = -1;
  long long l = 0, r = s;
  if (n == 1) {
    cout << s << '\n';
    return;
  }
  while (l <= r) {
    long long mid = l + (r - l) / 2;
    long long rem = s - mid;
    long long each = rem / nums_after;
    if (each >= mid) {
      ans = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  cout << ans << '\n';
}
int32_t main() {
  cin >> tt;
  while (tt--) {
    solve();
  }
}
