#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, T2 y) {
  if (x < y) x = y;
}
using ll = long long;
using ld = long double;
const string FILENAME = "input";
void solve() {
  ll n;
  cin >> n;
  n--;
  ll id = n / 3;
  ll pos;
  int it = 0;
  for (ll i = 1;; i *= 4) {
    it++;
    if (i > id) {
      pos = i;
      break;
    }
    id -= i;
  }
  ll a = pos + id;
  ll b = pos * 2;
  ll g[4] = {0, 2, 3, 1};
  for (int i = 0; i < it - 1; i++) {
    pos /= 4;
    ll val = id / pos;
    b += pos * g[val];
    id %= pos;
  }
  if (n % 3 == 0) {
    cout << a;
  } else if (n % 3 == 1) {
    cout << b;
  } else {
    cout << (a ^ b);
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
