#include <bits/stdc++.h>
using namespace std;
long long next_val[] = {0, 2, 3, 1};
vector<long long> v;
long long find_se(long long base_value, long long pos, long long width) {
  if (width == 0) {
    return base_value;
  }
  return find_se(base_value + width * next_val[pos / width], pos % width,
                 width / 4);
}
int main() {
  long long t;
  long long n;
  cin >> t;
  while (t--) {
    cin >> n;
    long long base = (n - 1) / 3;
    long long type = (n - 1) % 3;
    long long i = 0;
    long long cummulative = 0;
    while (base >= (1ll << (2 * i)) + cummulative) {
      cummulative += 1ll << (2 * i);
      i++;
    }
    long long relative_base = base - cummulative;
    long long base_value = 1ll << (2 * i);
    long long fe = relative_base + base_value;
    long long se = 0;
    if (type == 0) {
      cout << fe;
    } else {
      se = find_se(base_value << 1ll, relative_base, base_value / 4);
      if (type == 1) {
        cout << se;
      } else {
        cout << (fe ^ se);
      }
    }
    cout << "\n";
  }
}
