#include <bits/stdc++.h>
using namespace std;
long long n, nn, p, pp, tt;
int k, _s, t;
char s[105];
int main() {
  for (scanf("%d", &t); t--;) {
    _s = k = 0;
    p = 1;
    scanf("%lld", &n);
    nn = n;
    while (nn) {
      nn /= 4;
      p *= 4;
      k++;
    }
    p /= 4;
    pp = n - p;
    tt = pp / 3;
    for (int i = 1; i <= k - 1; i++) {
      if (tt % 4 == 0) {
        s[_s++] = '0';
        s[_s++] = '0';
      } else if (tt % 4 == 1) {
        if (pp % 3 == 0) {
          s[_s++] = '1';
          s[_s++] = '0';
        } else if (pp % 3 == 1) {
          s[_s++] = '0';
          s[_s++] = '1';
        } else {
          s[_s++] = '1';
          s[_s++] = '1';
        }
      } else if (tt % 4 == 2) {
        if (pp % 3 == 0) {
          s[_s++] = '0';
          s[_s++] = '1';
        } else if (pp % 3 == 1) {
          s[_s++] = '1';
          s[_s++] = '1';
        } else {
          s[_s++] = '1';
          s[_s++] = '0';
        }
      } else {
        if (pp % 3 == 0) {
          s[_s++] = '1';
          s[_s++] = '1';
        } else if (pp % 3 == 1) {
          s[_s++] = '1';
          s[_s++] = '0';
        } else {
          s[_s++] = '0';
          s[_s++] = '1';
        }
      }
      tt /= 4;
    }
    if (pp % 3 == 0)
      s[_s++] = '1';
    else if (pp % 3 == 1) {
      s[_s++] = '0';
      s[_s++] = '1';
    } else {
      s[_s++] = '1';
      s[_s++] = '1';
    }
    long long ans = 0;
    for (int i = 0; i < _s; i++)
      if (s[i] == '1') {
        ans |= 1LL << i;
      }
    printf("%lld\n", ans);
  }
  return 0;
}
