#include <bits/stdc++.h>
using namespace std;
const long long mk = 100005;
long long n;
vector<long long> g[mk];
long long find(long long A) {
  if (A == 0) return 0;
  long long tmp = A & 3;
  long long R = (find(A / 4) << 2);
  if (tmp == 0) return R;
  if (tmp == 1) return (R | 2);
  if (tmp == 2) return (R | 3);
  if (tmp == 3) return (R | 1);
}
void init() {
  long long test;
  cin >> test;
  for (long long i = 1; i <= test; i++) {
    long long n;
    cin >> n;
    long long root = 1;
    while (root * 4 <= n) root *= 4;
    n -= (root - 1);
    long long A = (root | ((n - 1) / 3));
    long long B = find(A);
    long long C = A ^ B;
    if (n % 3 == 1) cout << A;
    if (n % 3 == 2) cout << B;
    if (n % 3 == 0) cout << C;
    cout << "\n";
  }
}
signed main() { init(); }
