#include <bits/stdc++.h>
using namespace std;
int t;
long long n;
int main() {
  cin >> t;
  for (int cas = 1; cas <= t; ++cas) {
    cin >> n;
    long long row = (n + 2) / 3;
    long long col = 3;
    if (n % 3 != 0) {
      col = n - n / 3 * 3;
    }
    long long pw = 1LL;
    while (pw < row) {
      row -= pw;
      pw *= 4LL;
    }
    long long a = pw + row - 1;
    long long b = pw * 2LL;
    for (long long p = pw / 4; p >= 1; p /= 4) {
      long long r = (row - 1) / p;
      if (r == 1)
        b += p * 2;
      else if (r == 2)
        b += 2 * p + p;
      else if (r == 3)
        b += p;
      row = row - r * p;
    }
    if (col == 1)
      cout << a << endl;
    else if (col == 2)
      cout << b << endl;
    else
      cout << (a ^ b) << endl;
  }
  return 0;
}
