#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
const int ff[4] = {0, 2, 3, 1};
int main() {
  int cas;
  scanf("%d", &cas);
  while (cas--) {
    long long n;
    scanf("%lld", &n);
    long long g = (n - 1) / 3 + 1;
    int id = (n - 1) % 3 + 1;
    int B = 0;
    long long N = 1;
    while (g > N) {
      g -= N;
      N *= 4;
      B++;
    }
    g--;
    long long x = N + g;
    long long y = 1ll << (B * 2 + 1);
    for (int i = (0); i <= (B - 1); i++) {
      long long t = (x >> (i * 2)) & 3;
      long long tt = ff[t];
      y += tt << (i * 2);
    }
    long long z = x ^ y;
    if (id == 1) printf("%lld\n", x);
    if (id == 2) printf("%lld\n", y);
    if (id == 3) printf("%lld\n", z);
  }
  return 0;
}
