#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx,
                minn, temp, ans, flag, g, ts;
  char ch, chh;
  double dans;
  string str, ttr;
  cin >> t;
  for (ts = 1; ts <= t; ts++) {
    flag = 0;
    sum = 0;
    cnt = 0;
    ans = 0;
    k = 0;
    maxx = 0;
    minn = 0;
    a = 0;
    b = 0;
    temp = 0;
    cin >> n >> k;
    x = (k / n);
    temp = x;
    k += x;
    while (x != 0) {
      x = (k / n);
      x = (x - temp);
      temp = (k / n);
      k += x;
    }
    cout << k;
    cout << "\n";
  }
  return 0;
}
