#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int tt;
  cin >> tt;
  while (tt--) {
    int n, k;
    cin >> n >> k;
    int ans = k, to_add = k / n;
    int rem = (n - k % n) % n;
    if (to_add < rem) {
      ans += to_add;
    } else {
      ans += rem;
      to_add -= rem > 0 ? (rem - 1) : 0;
      ans += (to_add / (n - 1)) * n + (to_add % (n - 1));
      if (ans % n == 0) --ans;
    }
    cout << ans << "\n";
  }
  return 0;
}
