#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long g = log2(n);
    if (g % 2) g--;
    n -= pow(2, g);
    long long l = pow(2, g) + (n / 3);
    if (!l) l = 1;
    bitset<60> b = l;
    bitset<60> x = l;
    for (int i = 0; i < 60; i += 2) {
      if (b[i] == 0 && b[i + 1] == 0) {
        x[i] = 0, x[i + 1] = 0;
      } else if (b[i] == 1 && b[i + 1] == 0) {
        x[i] = 0, x[i + 1] = 1;
      } else if (b[i] == b[i + 1]) {
        x[i] = 1, x[i + 1] = 0;
      } else {
        x[i] = 1, x[i + 1] = 1;
      }
    }
    if (n % 3 == 0)
      cout << l << endl;
    else {
      if ((n - 1) % 3 == 0) {
        cout << (long long)(x).to_ullong() << endl;
      } else
        cout << (long long)(b ^ x).to_ullong() << endl;
    }
  }
}
