#include <bits/stdc++.h>
using namespace std;
const long long N = 200100;
struct WORK {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
long long a[5], b[311111], u[311111];
vector<long long> g[111111];
set<long long> s;
long long n;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    long long k = 1;
    while (k * 4 <= n) {
      k *= 4;
    }
    a[1] = 0;
    a[2] = 2;
    a[3] = 3;
    a[4] = 1;
    b[1] = (n - k) / 3 + k;
    long long bg = k * 2;
    long long ans = 0;
    long long x = k / 4;
    while (1) {
      if (x == 0) break;
      if (x == 1) {
        ans += a[b[1] - k + 1];
        break;
      }
      long long block = 1;
      while (k + x <= b[1]) {
        k += x;
        block++;
      }
      ans += a[block] * x;
      x /= 4;
      if (x == 0) break;
    }
    b[2] = bg + ans;
    b[3] = b[1] ^ b[2];
    if (n % 3 == 0) {
      cout << b[3];
    } else {
      cout << b[n % 3];
    }
    cout << "\n";
  }
}
