#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a = 0;
    long long b = k / n;
    while (b != a) {
      k += b - a;
      a = b;
      b = k / n;
    }
    cout << k << endl;
  }
  return 0;
}
