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