#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long p = 0;
    while (powl(2, p + 2) - 1 < n) p += 2;
    n -= (powl(2, p) - 1);
    long long num = (n + 2) / 3;
    num--;
    long long num2 = 0, num3 = 0;
    for (long long i = 0; powl(2, i) <= num; i += 2) {
      if (!(num & ((long long)1 << i)) && !(num & ((long long)1 << (i + 1))))
        continue;
      if ((num & ((long long)1 << i)) && (num & ((long long)1 << (i + 1)))) {
        num2 += (long long)((long long)1 << i);
        num3 += (long long)((long long)1 << (i + 1));
      } else if ((num & ((long long)1 << i))) {
        num2 += (long long)((long long)1 << (i + 1));
        num3 += (long long)((long long)1 << (i + 1));
        num3 += (long long)((long long)1 << i);
      } else {
        num3 += (long long)((long long)1 << (i));
        num2 += (long long)((long long)1 << (i + 1));
        num2 += (long long)((long long)1 << i);
      }
    }
    long long ans = 0;
    if (n % (long long)3 == (long long)1) {
      ans += num;
      ans += (long long)((long long)1 << p);
    } else if (n % (long long)3 == (long long)2) {
      ans += num2;
      ans += (long long)((long long)2 << p);
    } else {
      ans += num3;
      ans += (long long)((long long)3 << p);
    }
    cout << ans << '\n';
  }
  return 0;
}
