#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int M = 1e9 + 7;
const long double PI = acos(-1);
long long t, n;
long long a[100], b[5][4][3] = {{{0, 0}, {0, 0}, {0, 0}},
                                {{0, 1}, {1, 0}, {1, 1}},
                                {{1, 0}, {1, 1}, {0, 1}},
                                {{1, 1}, {0, 1}, {1, 0}}};
void Test() {
  cin >> n;
  long long pw = 1, i;
  for (i = 0; i < 70; i++) a[i] = 0;
  while (pw * 3 < n) n -= pw * 3, pw *= 4;
  long long block = n / 3 - (n % 3 == 0);
  long long e = log2(pw) / 2;
  n %= 3;
  --n;
  if (n == -1) n = 2;
  long long t = 0;
  a[1] = block;
  for (i = 1; i <= e; i++) {
    a[i] += t;
    t = a[i] / 4;
    a[i] %= 4;
  }
  a[e + 1] = 1;
  long long nr = 0;
  for (i = 1; i <= e + 1; i++) {
    if (b[a[i]][n][0] == 1) nr += 1ll << (2 * (i - 1) + 1);
    if (b[a[i]][n][1] == 1) nr += 1ll << (2 * (i - 1));
  }
  cout << nr << '\n';
}
signed main() {
  cin >> t;
  while (t--) Test();
  return 0;
}
