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