#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  long long n, n1, k, k1;
  cin >> t;
  int a1[3][2] = {{0, 1}, {1, 0}, {1, 1}};
  int a[4][3][2] = {{{0, 0}, {0, 0}, {0, 0}},
                    {{0, 1}, {1, 0}, {1, 1}},
                    {{1, 0}, {1, 1}, {0, 1}},
                    {{1, 1}, {0, 1}, {1, 0}}};
  while (t--) {
    vector<int> v;
    cin >> n;
    n1 = n;
    n = n - 4;
    long long h = 3;
    while (n >= 0) {
      k1 = (n / h) % 4;
      k = (n) % 3;
      v.push_back(a[k1][k][1]);
      v.push_back(a[k1][k][0]);
      if (h == 4)
        h = 12;
      else
        h = h * 4;
      n = n - h;
    }
    k = (n1 - 1) % 3;
    v.push_back(a1[k][1]);
    v.push_back(a1[k][0]);
    long long ans = 0;
    for (int i = 0; i < v.size(); i++) {
      ans = ans + pow(2, i) * v[i];
    }
    cout << ans << "\n";
  }
}
