#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, m, sum;
    cin >> n >> m;
    if (m % (n - 1) != 0) {
      sum = (m % (n - 1)) + n * ((m / (n - 1)));
      cout << sum << "\n";
    } else {
      sum = n * ((m / (n - 1))) - 1;
      cout << sum << "\n";
    }
  }
  return 0;
}
