#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long p4 = 1;
    while (p4 * 4 <= n) p4 *= 4;
    long long k = p4 + (n - p4) / 3;
    if (n % 3 == 1) {
      cout << k << endl;
    } else if (n % 3 == 2) {
      long long ans = 2;
      k ^= p4;
      while (p4 > 1) {
        ans *= 4;
        p4 /= 4;
        long long x = k / p4;
        k %= p4;
        switch (x) {
          case 0:
            break;
          case 1:
            ans += 2;
            break;
          case 2:
            ans += 3;
            break;
          case 3:
            ans += 1;
            break;
        }
      }
      cout << ans << '\n';
    } else {
      long long ans = 3;
      k ^= p4;
      while (p4 > 1) {
        ans *= 4;
        p4 /= 4;
        long long x = k / p4;
        k %= p4;
        switch (x) {
          case 0:
            break;
          case 1:
            ans += 3;
            break;
          case 2:
            ans += 1;
            break;
          case 3:
            ans += 2;
            break;
        }
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
