#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  vector<long long> remove;
  for (int i = 1; i < 101010; i++) {
    remove.push_back(1ll * i * (i - 1) / 2);
  }
  while (t--) {
    int x, n;
    cin >> n >> x;
    int l = 0, r = x + 1;
    while (l < r - 1) {
      int m = (l + r) / 2;
      if (m - (lower_bound(remove.begin(), remove.end(), m) - remove.begin()) >=
          x) {
        r = m;
      } else {
        l = m;
      }
    }
    cout << r << endl;
  }
}
