#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int b[10] = {0, 2, 3, 1}, a[maxn];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long n, ans = 1;
    cin >> n;
    int m = n % 3;
    n = (n + 2) / 3;
    while (n > ans) {
      n -= ans;
      ans *= 4;
    }
    int cnt = 0;
    long long ans1 = ans + n - 1, ans2 = ans * 2;
    n--;
    while (n) {
      a[++cnt] = n % 4;
      n /= 4;
    }
    long long now = 1;
    for (int i = 1; i <= cnt; i++) ans2 += b[a[i]] * now, now *= 4;
    if (m == 1)
      cout << ans1 << endl;
    else if (m == 2)
      cout << ans2 << endl;
    else if (m == 0)
      cout << (ans1 ^ ans2) << endl;
  }
}
