#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll flog2(ll n) {
  ll res = 0;
  while (n >>= 1) res++;
  return res;
}
ll uno = 1;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    n--;
    ll ter = n / 3;
    ll ub = 0, p = 0;
    while (ter > ub) {
      p += 2;
      ub += (uno << p);
    }
    ll diff = (uno << p) - 1 - (ub - ter);
    ll a = (uno << p) + diff;
    ll loga = flog2(a);
    ll b = 0;
    for (int i = 0; i < loga; i++) {
      ll bs = uno << (i / 2) * 2;
      ll bn = diff / bs;
      if (i % 2 == 0) {
        if (bn % 4 > 1) b |= (uno << i);
      } else {
        if (bn % 4 == 1 || bn % 4 == 2) b |= (uno << i);
      }
    }
    b |= (uno << loga + 1);
    ll c = a ^ b;
    if (n % 3 == 0)
      cout << (long long)a << endl;
    else if (n % 3 == 1)
      cout << (long long)b << endl;
    else
      cout << (long long)c << endl;
  }
}
