#include <bits/stdc++.h>
using namespace std;
long long int maxx = INT_MIN;
long long int minx = INT_MAX;
vector<long long int> readArr(vector<long long int> &a, long long int n) {
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    a.push_back(x);
  }
  return a;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    unsigned long long int l = 0;
    unsigned long long int r = 1e14;
    while (1) {
      unsigned long long int mid = l + (r - l) / 2;
      unsigned long long int cmp = mid - mid / n;
      if (k == cmp) {
        if (mid % n)
          cout << mid << endl;
        else
          cout << mid - 1 << endl;
        break;
      } else if (k > cmp) {
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
  }
  return 0;
}
