#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int MOD = 1e9 + 7;
const long long SEED = 1333331;
const int N = 1e6 + 10, M = N + N;
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  cout << m / (n - 1) * n + (m % (n - 1) == 0 ? -1 : m % (n - 1)) << endl;
  return;
}
int main() {
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
