#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    long long n, k;
    cin >> n >> k;
    long long a = 1, r;
    while ((r = k / n - a / n) > 0) {
      a = k;
      k += r;
    }
    cout << k << '\n';
  }
  return 0;
}
