#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long num = (n - 1) / 3 + 1;
    long long k = 1;
    long long st = 0;
    long long sum = 1;
    while (sum < num) {
      k *= 4;
      sum += k;
      st += 2;
    }
    num -= sum - k + 1;
    long long a = pow(2, st) + num;
    long long st2 = -1;
    long long b = 0;
    for (long long i = 0; i <= 60; i += 2) {
      if ((a & ((long long)1 << i)) && !(a & ((long long)1 << (i + 1)))) {
        b += pow(2, i + 1);
      } else if (!(a & ((long long)1 << i)) && (a & ((long long)1 << (i + 1))))
        b += pow(2, i + 1) + pow(2, i);
      else if ((a & ((long long)1 << i)) && (a & ((long long)1 << (i + 1))))
        b += pow(2, i);
    }
    cerr << "ans=";
    if (n % 3 == 1)
      cout << a << "\n";
    else if (n % 3 == 2)
      cout << min(b, a ^ b) << "\n";
    else
      cout << max(b, a ^ b) << "\n";
  }
}
