#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long r = 254;
    cin >> r;
    long long k = (r + 2) / 3;
    long long p = 3, pp = 0, d = 3, ss = 3;
    while (r > p) {
      p = ss + (d * 4);
      ss = p;
      d *= 4;
    }
    long long t = (p + 1) / 2;
    t--;
    long long y = p / 3;
    t -= (y - k);
    long long q = r % 3;
    if (q == 0) q = 3;
    long long w = (p + 1) / 2;
    w = (w + 1) / 2;
    d = t - w;
    r = w * 2;
    p = d;
    y = 1;
    long long val[4];
    val[0] = 0;
    val[1] = 2;
    val[2] = 3;
    val[3] = 1;
    while (p) {
      r += val[(p % 4)] * y;
      p /= 4;
      y *= 4;
    }
    if (q == 1) {
      cout << t << "\n";
    } else if (q == 2) {
      cout << r << "\n";
    } else {
      cout << (t ^ r) << "\n";
    }
  }
}
