#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0LL) return b;
  if (b == 0LL) return a;
  return gcd(b, a % b);
}
const int N = 10000;
void solve() {
  long long n;
  cin >> n;
  long long n1 = (n + 2) / 3LL;
  long long nbits = 1;
  long long len = 0;
  while ((len + (1LL << (nbits - 1))) < n1) {
    len = len + (1LL << (nbits - 1));
    nbits += 2LL;
  }
  long long num1 = (1LL << (nbits - 1)) + n1 - len - 1LL;
  long long num2 = 0;
  for (long long i = 0; i < nbits; i += 2) {
    bool bit2 = num1 & (1LL << i);
    bool bit1 = num1 & (1LL << (i + 1LL));
    if (!bit1 && bit2) num2 += (1LL << (i + 1LL));
    if (bit1 && !bit2) num2 += (1LL << (i + 1LL)) + (1LL << i);
    if (bit1 && bit2) num2 += (1LL << i);
  }
  long long num3 = num1 ^ num2;
  if (n % 3LL == 0) cout << num3 << "\n";
  if (n % 3LL == 1) cout << num1 << "\n";
  if (n % 3LL == 2) cout << num2 << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  clock_t clk = clock();
  int t = 1;
  cin >> t;
  for (int tests = 1; tests <= t; tests++) {
    solve();
  }
  clk = clock() - clk;
  cerr << "Time Elapsed: " << fixed << setprecision(10)
       << ((long double)clk) / CLOCKS_PER_SEC << "\n";
  return 0;
}
