#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    ll N;
    cin >> N;
    ll n = N;
    ll p = 4;
    while (p <= n) {
      p *= 4;
    }
    p /= 4;
    ll tri[3];
    tri[0] = p + (n - p) / 3;
    auto binary = [=](ll number) -> string {
      string b = "";
      while (number) {
        if (number & 1) {
          b += '1';
        } else {
          b += '0';
        }
        number >>= 1;
      }
      if (b.size() & 1) b += '0';
      return b;
    };
    string b1 = binary(tri[0]);
    string b2 = "";
    for (int i = 0; i < b1.size(); i += 2) {
      if (b1[i] == '1' and b1[i + 1] == '0') {
        b2 += '0';
        b2 += '1';
      } else if (b1[i] == '0' and b1[i + 1] == '1') {
        b2 += '1';
        b2 += '1';
      } else if (b1[i] == '1' and b1[i + 1] == '1') {
        b2 += '1';
        b2 += '0';
      } else {
        b2 += '0';
        b2 += '0';
      }
    }
    auto number = [=](string b) -> ll {
      ll num = 0, p = 1;
      for (char c : b) {
        if (c == '1') {
          num += p;
        }
        p <<= 1;
      }
      return num;
    };
    tri[1] = number(b2);
    tri[2] = tri[0] ^ tri[1];
    cout << (tri[(n - p) % 3]) << '\n';
  }
}
