#include <bits/stdc++.h>
using namespace std;
long long v[] = {0, 2, 3, 1};
int main() {
  int t;
  long long n;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld", &n);
    long long p;
    for (p = 1; p <= n; p *= 4)
      ;
    p /= 4;
    long long d = n - p, r = d / 3, r2 = r;
    long long val = 2 * p;
    long long j = 0;
    while (r) {
      val = val | (v[r % 4] << (2 * j));
      r /= 4;
      j++;
    }
    if (n % 3 == 1)
      printf("%lld\n", p + r2);
    else if (n % 3 == 2)
      printf("%lld\n", val);
    else
      printf("%lld\n", (p + r2) ^ val);
  }
  return 0;
}
