#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long n;
    scanf("%lld", &n);
    long long p = (n - 1) / 3, a = 1, cnt = 0;
    while (cnt < p) {
      if (cnt + a <= p) {
        cnt += a;
        a *= 4;
      } else {
        a += p - cnt;
        cnt = p;
      }
    }
    if ((n - 1) % 3 == 0)
      printf("%lld\n", a);
    else {
      long long b = 0;
      for (int i = 0; i <= 30; i++) {
        long long x = (1ll << (2 * i + 1));
        long long y = (1ll << (2 * i));
        if (!(a & x) && !(a & y)) b |= 0;
        if (!(a & x) && (a & y)) b |= x;
        if ((a & x) && !(a & y)) b |= x | y;
        if ((a & x) && (a & y)) b |= y;
      }
      if ((n - 1) % 3 == 1)
        printf("%lld\n", b);
      else
        printf("%lld\n", a ^ b);
    }
  }
}
