#include <bits/stdc++.h>
using namespace std;
long long n;
void solve() {
  cin >> n;
  long long a = (n - 1) / 3, b = n % 3, cnt;
  for (cnt = 0; a >= (1LL << 2 * cnt); ++cnt) a -= (1LL << 2 * cnt);
  a += (1LL << 2 * cnt);
  long long ans[3] = {0, a, 0};
  for (int i = 0; a; a >>= 2, ++i) {
    if ((a & 3) == 1)
      ans[0] += 3LL << 2 * i, ans[2] += 2LL << 2 * i;
    else if ((a & 3) == 2)
      ans[0] += 1LL << 2 * i, ans[2] += 3LL << 2 * i;
    else if ((a & 3) == 3)
      ans[0] += 2LL << 2 * i, ans[2] += 1LL << 2 * i;
  }
  cout << ans[b] << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) solve();
}
