#include <bits/stdc++.h>
using namespace std;
string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
using ld = long double;
using ui = uint_fast32_t;
using ll = int_fast64_t;
using ul = uint_fast64_t;
ll nimMul(ll x, ll y);
ll nimMulTwoPower(int x, int y) {
  if (!x || !y) return 1LL << (x | y);
  ll r = 1;
  for (int i = 0, v = x ^ y; v >> i; ++i)
    if (v & (1LL << i)) r <<= 1LL << i;
  for (int i = 0, v = x & y; v >> i; ++i)
    if (v & (1LL << i)) r = nimMul(r, 3LL << ((1LL << i) - 1));
  return r;
}
ll nimMul(ll x, ll y) {
  if (!x || !y) return x | y;
  if (x == 1) return y;
  if (y == 1) return x;
  ll r = 0;
  for (int i = 0; x >> i; ++i)
    if (x & (1LL << i))
      for (int j = 0; y >> j; ++j)
        if (y & (1LL << j)) r ^= nimMulTwoPower(i, j);
  return r;
}
void solve() {
  ll n;
  cin >> n;
  --n;
  int m = n % 3;
  n /= 3;
  int i;
  ll p;
  for (i = 0, p = 1;; i += 2, p <<= 2) {
    if (n >= p)
      n -= p;
    else {
      n += p;
      break;
    }
  }
  cout << nimMul(n, m + 1) << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
}
