#include <bits/stdc++.h>
using namespace std;
uint64_t solve(uint64_t n) {
  if (n <= 3) return n;
  n -= 1;
  uint64_t block = (n / 3) - 1;
  for (int hi = 2;; hi += 2) {
    if (block >= (1ULL << hi)) {
      block -= (1ULL << hi);
      continue;
    }
    uint64_t first = (1ULL << hi) + block;
    vector<int> sectors;
    uint64_t tmp = block;
    while (tmp) {
      constexpr int order[] = {0, 2, 3, 1};
      sectors.push_back(order[tmp % 4]);
      tmp /= 4;
    }
    reverse(sectors.begin(), sectors.end());
    uint64_t second = 0;
    for (int x : sectors) {
      second *= 4;
      second += x;
    }
    second += (1ULL << (hi + 1));
    uint64_t third = (first ^ second);
    uint64_t nums[] = {first, second, third};
    return nums[n % 3];
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    uint64_t n;
    cin >> n;
    cout << solve(n) << '\n';
  }
  return 0;
}
