#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  n--;
  long long r = n % 3;
  n /= 3;
  long long u = 0;
  while (n >= (1ll << u)) {
    n -= (1ll << u);
    u += 2;
  }
  long long a[3];
  a[0] = (1ll << u);
  a[1] = 2 * a[0];
  a[2] = 3 * a[0];
  long long t = 0;
  while (n) {
    long long kek = n % 4;
    long long y = (1ll << t);
    if (kek == 0) {
    }
    if (kek == 1) {
      a[0] += 1 * y;
      a[1] += 2 * y;
      a[2] += 3 * y;
    } else if (kek == 2) {
      a[0] += 2 * y;
      a[1] += 3 * y;
      a[2] += 1 * y;
    } else if (kek == 3) {
      a[0] += 3 * y;
      a[1] += 1 * y;
      a[2] += 2 * y;
    }
    n /= 4;
    t += 2;
  }
  cout << a[r] << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
}
