#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  long long l = 0, r = 1e15;
  while (r - l > 1) {
    long long mid = (l + r) >> 1;
    if (mid - mid / n >= m) {
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%lld\n", r);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
