#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  int test;
  cin >> test;
  while (test--) {
    cin >> n >> k;
    long long lo = k, hi = 2 * k;
    while (lo < hi) {
      long long mid = (lo + hi) / 2;
      if (mid - mid / n >= k)
        hi = mid;
      else
        lo = mid + 1;
    }
    cout << lo << endl;
  }
}
