#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int t;
int main() {
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long p = (n - 1) / 3, s = 1, all = 0;
    while (p >= s) {
      p -= s;
      s <<= 2;
    }
    if (n % 3 == 2) {
      long long ans = s << 1, c = 1;
      while (p) {
        long long x = p % 4;
        if (x == 1)
          ans += c * 2;
        else if (x == 2)
          ans += c * 3;
        else if (x == 3)
          ans += c;
        p >>= 2;
        c <<= 2;
      }
      cout << ans << endl;
    } else if (n % 3 == 1) {
      cout << s + p << endl;
    } else {
      long long ans = s * 3;
      long long c = 1;
      while (p) {
        long long x = p % 4;
        if (x == 1)
          ans += c * 3;
        else if (x == 2)
          ans += c;
        else if (x == 3)
          ans += c * 2;
        p >>= 2;
        c <<= 2;
      }
      cout << ans << endl;
    }
  }
}
