#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> k >> n;
    long long int l = n, r = 0;
    while (1) {
      r = n - (n / k);
      if (r == l) break;
      n += (l - r);
    }
    cout << n << "\n";
  }
}
