#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1, c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
long long calc(long long L, long long R, long long p) {
  if (L + 1 == R) return L;
  long long x = (R - L) / 4;
  if (p <= x) return calc(L, L + x, p);
  if (p <= x * 2) return calc(L + x * 2, L + x * 3, p - x);
  if (p <= x * 3) return calc(L + x * 3, R, p - x * 2);
  return calc(L + x, L + x * 2, p - x * 3);
}
long long n, L, R, fi, se;
inline void solve() {
  n = read();
  long long p = (n + 2) / 3;
  for (long long i = 0;; i += 2) {
    if (p <= (1ll << i)) {
      L = 1ll << (i + 1);
      R = 3 * (1ll << i);
      fi = (1ll << i) + p - 1;
      break;
    }
    p -= 1ll << i;
  }
  if (n % 3 == 1) {
    cout << fi << "\n";
    return;
  }
  se = calc(L, R, p);
  if (n % 3 == 2)
    cout << se << "\n";
  else
    cout << (fi ^ se) << "\n";
}
signed main() {
  for (long long T = read(); T--;) solve();
  return (0 - 0);
}
