#include <bits/stdc++.h>
using namespace std;
const long long N = 100005, mod = 1000000007, M = 5005;
long long n, m, k, i, j, ans, kaskad[N];
void GetSecond(long long first, long long& second) {
  long long four = 1;
  while (first != 0) {
    long long mnac = first % 4;
    first /= 4;
    if (mnac == 1)
      second += four * 2;
    else if (mnac == 2)
      second += four * 3;
    else if (mnac == 3)
      second += four;
    four *= 4;
  }
}
void solve() {
  long long ans[3]{};
  cin >> n;
  long long ast = 2;
  while (n >= (1ll << ast)) {
    ast += 2;
  }
  long long ind = n - (1ll << (ast - 2));
  long long group = ind / 3;
  ans[0] = (1ll << (ast - 2)) + group;
  GetSecond(ans[0], ans[1]);
  ans[2] = (ans[0] ^ ans[1]);
  cout << ans[ind % 3] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long tests = 1;
  cin >> tests;
  while (tests--) {
    solve();
  }
  return 0;
}
