#include <bits/stdc++.h>
using namespace std;
inline long long gi() {
  long long f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
inline long long gl() {
  long long f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
const long long N = 200003, M = N << 1;
long long n, m;
long long a[N], b[N];
char s[N];
signed main() {
  long long T = 1;
  T = gi();
  while (T--) {
    n = gi(), m = gi();
    long long now = m / (n - 1) + 1;
    if (m % (n - 1) == 0) --now;
    long long len = (now - 1) * n, len1 = (now - 1) * (n - 1);
    printf("%lld\n", len + m - len1);
  }
  return 0;
}
