#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll get(ll x) {
  std::vector<int> kal;
  ll q = 1;
  while (x != 0) {
    kal.push_back(x % 4);
    if (x / 4 > 0) q *= 4;
    x /= 4;
  }
  reverse(kal.begin(), kal.end());
  ll ans = 0;
  for (int i : kal) {
    if (i == 1) {
      ans += q * 2;
    }
    if (i == 2) {
      ans += q * 3;
    }
    if (i == 3) {
      ans += q;
    }
    q /= 4;
  }
  return ans;
}
void solve() {
  ll n;
  cin >> n;
  ll k = (n - 1) / 3 + 1;
  ll start;
  for (start = 1; k > start; start *= 4) {
    k -= start;
  }
  ll a = start + k - 1;
  ll b = start * 2 + get(k - 1);
  if (n % 3 == 1) {
    cout << a << "\n";
  } else if (n % 3 == 2) {
    cout << b << "\n";
  } else {
    cout << (a ^ b) << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  for (; t > 0; t--) {
    solve();
  }
  return 0;
}
