#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
int t[] = {0, 2, 3, 1};
class E {
 public:
  ll get_first(ll n) {
    if (n == 0) return 1;
    return 4 * get_first((n - 1) / 4) + (n - 1) % 4;
  }
  ll get_second(ll n) {
    if (n == 0) return 2;
    return 4 * get_second((n - 1) / 4) + t[(n - 1) % 4];
  }
  int testNumber = 0;
  void solve(istream& in, ostream& out) {
    ll n;
    in >> n;
    n -= 1;
    ll a = get_first(n / 3);
    ll b = get_second(n / 3);
    if (n % 3 == 1) swap(a, b);
    if (n % 3 == 2) a ^= b;
    out << a << endl;
  }
};
int main() {
  E solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  int n;
  in >> n;
  for (int i = 0; i < n; ++i) {
    solver.solve(in, out);
  }
  return 0;
}
