#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<long long> mapper = {0, 2, 3, 1};
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long cur = 1;
    while (cur <= n) cur <<= 2;
    cur >>= 2;
    long long diff = n - cur;
    long long row = diff / 3;
    long long a = cur + row;
    if (diff % 3 == 0)
      cout << a << '\n';
    else {
      int pos = 0;
      long long b = 0;
      while (a >> pos) {
        b |= mapper[(a >> pos) & 3ll] << pos;
        pos += 2;
      }
      cout << (diff % 3 == 1 ? b : (a ^ b)) << '\n';
    }
  }
  return 0;
}
