#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
void cal(long long x) {
  long long now = 1;
  b = c = 0;
  while (x > 0) {
    if (x % 4 == 1) {
      b += 2 * now;
      c += 3 * now;
    }
    if (x % 4 == 2) {
      b += 3 * now;
      c += now;
    }
    if (x % 4 == 3) {
      b += now;
      c += 2 * now;
    }
    x /= 4;
    now *= 4;
  }
}
int main() {
  int T;
  long long n;
  scanf("%d", &T);
  while (T--) {
    scanf("%lld", &n);
    long long x = (n - 1) / 3 + 1;
    long long now = 1;
    a = 1;
    while (x > now) {
      x -= now;
      a *= 4;
      now *= 4;
    }
    a += x - 1;
    cal(a);
    if (n % 3 == 1) printf("%I64d\n", a);
    if (n % 3 == 2) printf("%I64d\n", b);
    if (n % 3 == 0) printf("%I64d\n", c);
  }
  return 0;
}
