#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
const int mod = 1e9 + 7;
long long v[] = {0, 2, 3, 1};
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long x = ceil(n / 3.0);
    long long go = 1, cur = 1;
    while (cur < x) {
      go *= 4;
      cur += go;
    }
    cur -= go;
    long long limInf = go;
    long long limSup = 2 * go - 1;
    long long A = limInf + (x - cur) - 1;
    long long lowest = 2 * go;
    x -= cur + 1;
    while (limInf < limSup) {
      long long ran = ((x) / ((limSup - limInf + 1) / 4ll)) % 4;
      x -= ((limSup - limInf + 1) / 4ll) * ran;
      lowest += ((limSup - limInf + 1) / 4ll) * v[ran];
      limSup = lowest + ((limSup - limInf + 1) / 4ll) - 1;
      limInf = lowest;
    }
    long long B = lowest;
    long long C = A ^ B;
    if (n % 3 == 1)
      cout << A << '\n';
    else if (n % 3 == 2)
      cout << B << '\n';
    else
      cout << C << '\n';
  }
}
