#include <bits/stdc++.h>
using namespace std;
bool SortbySecDesc(const pair<long long, long long> &a,
                   const pair<long long, long long> &b) {
  return a.second > b.second;
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  ;
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long low = 1, high = 1e18, ans;
    while (low <= high) {
      long long mid = (low + high) / 2;
      long long vag = mid / a;
      long long baki = mid - vag;
      if (baki >= b) {
        ans = mid;
        high = mid - 1;
      } else {
        low = mid + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
