#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int arr[10];
set<long long> st;
int main() {
  long long test;
  cin >> test;
  for (int i = 0; i < test; i++) {
    long long n, k;
    cin >> n >> k;
    long long res = 0, res2 = 0;
    long long prev = 0;
    while (true) {
      res = (k / n);
      k += (k / n) - prev;
      prev = res;
      if (res == (k / n)) break;
    }
    cout << k << endl;
  }
}
