#include <bits/stdc++.h>
using namespace std;
int a[2000];
int t, n, k;
int ans;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n, &k);
    int m = 0, res = 0;
    ans = 0;
    m = k / (n - 1);
    ans = k - m * (n - 1);
    if (k == m * (n - 1)) ans--;
    ans += m * n;
    cout << ans << endl;
  }
  return 0;
}
