#include <bits/stdc++.h>
using namespace std;
const int mx[] = {0, 2, 3, 1};
long long get_base(long long n) {
  long long b = 4;
  for (;;) {
    if (b > n) return b / 4;
    b <<= 2;
  }
  return 0;
}
long long func1(long long n) {
  long long b = get_base(n);
  return (n - b) / 3 + b;
}
long long func2(long long n) {
  long long b = get_base(n);
  long long m = (n - b - 1) / 3;
  long long bb = b;
  vector<int> v;
  while (bb >= 4) {
    v.push_back(m % 4);
    m /= 4;
    bb /= 4;
  }
  long long r = b + b;
  bb = b / 4;
  for (int i = v.size() - 1; i >= 0; i--) {
    r += bb * mx[v[i]];
    bb /= 4;
  }
  if (n == 2) return 2;
  return r;
}
int main() {
  int t;
  long long n, ans;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    if (n % 3 == 0)
      ans = func1(n - 2) ^ func2(n - 1);
    else if (n % 3 == 1)
      ans = func1(n);
    else
      ans = func2(n);
    cout << ans << endl;
  }
  return 0;
}
