#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
const long long INF = 1e17;
void form() {}
long long p[MAXN] = {0, 1}, b[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long limit = 0;
  for (int i = 2; i <= INF; i++) {
    p[i] = p[i - 1] * 4;
    if (p[i] > INF) {
      limit = i;
      break;
    }
  }
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    memset(b, 0, sizeof(b));
    long long index = upper_bound(p + 1, p + 1 + limit, n) - p - 1;
    long long id = (n - p[index]) % 3, fir = p[index] + (n - p[index]) / 3;
    long long temp = fir, cnt = 0;
    while (temp) {
      b[cnt++] = temp % 2;
      temp /= 2;
    }
    for (int i = 0; i < cnt; i += 2) {
      if (b[i] == 1 && b[i + 1] == 0)
        b[i] = 0, b[i + 1] = 1;
      else if (b[i] == 1 && b[i + 1] == 1)
        b[i + 1] = 0;
      else if (b[i] == 0 && b[i + 1] == 1)
        b[i] = 1;
    }
    long long sec = 0, item = 1;
    for (int i = 0; i <= cnt; i++) {
      sec += b[i] * item;
      item *= 2;
    }
    long long third = fir ^ sec;
    switch (id) {
      case 0:
        cout << fir << endl;
        break;
      case 1:
        cout << sec << endl;
        break;
      case 2:
        cout << third << endl;
        break;
      default:
        break;
    }
  }
  return 0;
}
