#include <bits/stdc++.h>
using namespace std;
using Long = long long;
int main(void) {
  int t;
  cin >> t;
  while (t--) {
    Long n, k;
    cin >> n >> k;
    Long minVal = 1;
    Long maxVal = LONG_MAX;
    Long ans = 0;
    while (minVal <= maxVal) {
      Long currVal = minVal + (maxVal - minVal) / 2ll;
      Long notDivisible = currVal - currVal / n;
      if (notDivisible == k and currVal % n != 0) {
        ans = currVal;
        break;
      }
      if (notDivisible < k)
        minVal = currVal + 1;
      else
        maxVal = currVal - 1;
    }
    cout << ans << "\n";
  }
  return 0;
}
