#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, a, b, n, m, temp, temp1, temp2, temp3;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    temp1 = (m / (n - 1));
    if (temp1 * (n - 1) == m) {
      temp1--;
    }
    temp2 = temp1 * (n - 1);
    temp3 = m - temp2;
    cout << n * temp1 + temp3 << endl;
  }
}
