#include <bits/stdc++.h>
using namespace std;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fastio();
  long long int T = 1;
  cin >> T;
  for (long long int test = 1; test <= T; test++) {
    long long int n, m, k, ans, cnt, sum;
    ans = 0;
    cnt = 100;
    sum = 0;
    cin >> n >> k;
    if (k < n)
      ans = k;
    else {
      while (k && cnt--) {
        if (k < n) {
          ans += k;
          break;
        }
        long long int z = k / n;
        long long int a = z * n;
        z *= (n - 1);
        long long int q = k - z;
        ans += a;
        k = q;
      }
    }
    cout << ans << endl;
  }
}
