#include <bits/stdc++.h>
using namespace std;
long long cost[4][2] = {{0, 0}, {2, 3}, {3, 1}, {1, 2}};
long long get_a(long long N) {
  long long cnt = 1;
  while (cnt <= N) {
    N -= cnt;
    cnt *= 4;
  }
  return cnt + N;
}
void solve() {
  long long N;
  cin >> N;
  long long x = get_a((N - 1) / 3);
  long long f[3] = {x, 0, 0};
  for (long long pw = 1; pw <= x; pw *= 4) {
    int p = (x & (3 * pw)) / pw;
    f[1] += (cost[p][0] * pw);
    f[2] += (cost[p][1] * pw);
  }
  cout << f[(N - 1) % 3] << endl;
}
int main() {
  int tests;
  cin >> tests;
  while (tests--) {
    solve();
  }
  return 0;
}
