#include <bits/stdc++.h>
using namespace std;
const int nsize = 1e5 + 5;
const int inf = 1e9 + 5;
int main() {
  int TC;
  scanf("%d", &TC);
  for (int T = 1; T <= TC; T++) {
    int n, k;
    scanf(" %d %d", &n, &k);
    int ok = k;
    while (k - k / n < ok) k += ok - (k - k / n);
    printf("%d\n", k);
  }
  return 0;
}
