#include <bits/stdc++.h>
const int mod = 1e9 + 7;
long long add(long long x, long long y) { return (x + y) % mod; }
long long mul(long long x, long long y) { return (x * y) % mod; }
long long modulo(long long x, long long m) { return (x % m + m) % m; }
using namespace std;
void solve(void) {
  long long n, k;
  cin >> k >> n;
  if (k == 2) {
    cout << 2 * n - 1 << "\n";
    return;
  }
  long long m = n + n / k;
  while (m / k != n / k) {
    long long p = m;
    long long x = m / k - n / k;
    m += x;
    n = p;
  }
  cout << m << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
