#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
int T;
long long n;
int mp[]{0, 2, 3, 1};
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%lld", &n);
    long long p = 0, m = n;
    while (m) {
      m >>= 2;
      p++;
    }
    p--;
    long long a = (1ll << (2 * p)) + (n - 1) / 3 - ((1ll << (2 * p)) - 1) / 3,
              b = 0;
    for (int i = 0; i <= 2 * p; i += 2) {
      int c = ((a >> i) & 1) + 2 * ((a >> (i + 1)) & 1);
      b += (1ll * (mp[c]) << i);
    }
    int id = (n - 1) % 3 + 1;
    if (id == 1)
      printf("%lld\n", a);
    else if (id == 2)
      printf("%lld\n", b);
    else
      printf("%lld\n", a ^ b);
  }
  return 0;
}
