#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
long long f[4] = {0, 2, 3, 1};
long long B(long long a) { return (a == 1) ? 2 : f[a & 3] | B(a >> 2) << 2; }
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, A[3];
    cin >> n;
    long long d = 1;
    for (; n >= d; d <<= 2)
      ;
    d >>= 2;
    A[0] = d | ((n - d) / 3);
    A[1] = B(A[0]);
    A[2] = A[0] ^ A[1];
    cout << A[(n - d) % 3] << endl;
  }
}
