#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long long n, k;
    cin >> n >> k;
    long long count1 = k / n;
    long long nums = count1;
    while (nums != 0) {
      k += nums;
      nums = k / n - count1;
      count1 = k / n;
    }
    cout << k << endl;
  }
}
