#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
int main(void) {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    if (n == k) {
      cout << n + 1 << endl;
      continue;
    }
    if (k < n) {
      cout << k << endl;
      continue;
    }
    if (k % (n - 1) == 0) {
      long long t = k / (n - 1);
      cout << t * n - 1 << endl;
      continue;
    }
    if (k % (n - 1)) {
      long long t = k / (n - 1);
      long long r = k % (n - 1);
      cout << t * n + r << endl;
      continue;
    }
  }
  return 0;
}
