#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, k, ans = 0;
  cin >> n >> k;
  if (k < n)
    cout << k;
  else {
    while (k >= n) {
      ans += k - k % n;
      k = (k % n) + (k / n);
    }
    cout << ans + k;
  }
  cout << endl;
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
