#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    if (n > k) {
      cout << k << "\n";
    } else if (n == k) {
      cout << n + 1 << "\n";
    } else {
      long long a = k / (n - 1);
      if (k % (n - 1) == 0) {
        cout << a * n - 1 << "\n";
      } else {
        cout << a * n + k % (n - 1) << "\n";
      }
    }
  }
}
