#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m, t, i, j, k, x, y, z, p, q;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    x = m % (n - 1);
    if (x == 0) {
      long long ans = n * (m / (n - 1)) - 1;
      cout << ans << endl;
    } else {
      k = m - ((m / (n - 1)) * (n - 1));
      long long ans = (n * (m / (n - 1))) + k;
      cout << ans << endl;
    }
  }
}
