#include <bits/stdc++.h>
using namespace std;
struct piii {
  long long first, second, th;
  bool operator<(const piii &b) {
    if (first != b.first) return first < b.first;
    if (second != b.second) return second < b.second;
    return th < b.th;
  }
};
long long a[4] = {0, 1, 2, 3};
long long b[4] = {0, 2, 3, 1};
long long c[4] = {0, 3, 1, 2};
long long r[3];
long long n;
int main() {
  cout << setprecision(2) << fixed;
  ios::sync_with_stdio(false), cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    if (n < 4) {
      cout << n << endl;
      continue;
    }
    n -= 4;
    long long m = n / 3;
    long long i = 2;
    while (m >= (1ll << i)) m -= (1ll << i), i += 2;
    r[0] = (1ll << i);
    r[1] = (2ll << i);
    r[2] = (3ll << i);
    while (i > 0) {
      long long j = 0;
      while ((1ll << (i - 2)) * j <= m) j++;
      j--;
      m -= (1ll << (i - 2)) * j;
      r[0] += (a[j] << (i - 2));
      r[1] += (b[j] << (i - 2));
      r[2] += (c[j] << (i - 2));
      i -= 2;
    }
    cout << r[n % 3] << endl;
  }
  return 0;
}
