#include <bits/stdc++.h>
using namespace std;
long long u, n;
long long f[4] = {0, 2, 3, 1};
signed main() {
  cin >> u;
  while (u--) {
    cin >> n;
    n--;
    long long ln = n - n % 3;
    long long second = 1;
    while (second <= ln + 1) second *= 4;
    second /= 4;
    second = second + (ln - (second - 1)) / 3;
    if (n % 3 == 0) {
      cout << second << endl;
      continue;
    }
    long long aa = second;
    vector<long long> b4;
    while (second > 0) {
      b4.push_back(second % 4);
      second /= 4;
    }
    vector<long long> c4;
    for (auto q : b4) c4.push_back(f[q]);
    long long b = 0;
    for (long long i = (long long)(c4).size() - 1; i >= 0; i--)
      b = b * 4 + c4[i];
    if (n % 3 == 1)
      cout << b << endl;
    else
      cout << (aa ^ b) << endl;
  }
}
