#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 5;
string table[4][3] = {{"00", "00", "00"},
                      {"01", "10", "11"},
                      {"10", "11", "01"},
                      {"11", "01", "10"}};
long long calc(long long n) {
  long long i, j, k;
  long long a = 3, p = 1;
  while (n - a > 0) {
    n -= a;
    a *= 4;
    p++;
  }
  long long res = 0;
  long long position, portion, power;
  position = (n - 1) % 3;
  for (i = 1, a = 3, power = 1; i <= p; ++i) {
    portion = (((n + a - 1) / a) - 1) % 4;
    if (i == p) portion = 1;
    res = res + power * (table[portion][position][1] - '0');
    res = res + 2 * power * (table[portion][position][0] - '0');
    a *= 4;
    power *= 4;
  }
  return res;
}
int main() {
  long long t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << calc(n) << endl;
  }
  return 0;
}
