#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long tripleIndx = n / 3;
    if (!(n % 3)) tripleIndx--;
    stack<long long> st;
    while (tripleIndx--) {
      st.push(tripleIndx % 4ll);
      tripleIndx /= 4;
    }
    long long curA = 1;
    long long curB = 2;
    long long curC = 3;
    long long a[4] = {0, 1, 2, 3};
    long long b[4] = {0, 2, 3, 1};
    long long c[4] = {0, 3, 1, 2};
    while (!st.empty()) {
      long long mod = st.top();
      st.pop();
      curA *= 4;
      curA += a[mod];
      curB *= 4;
      curB += b[mod];
      curC *= 4;
      curC += c[mod];
    }
    if (n % 3 == 1) {
      cout << curA << "\n";
    } else if (n % 3 == 2) {
      cout << curB << "\n";
    } else {
      cout << curC << "\n";
    }
  }
  return 0;
}
