#include <bits/stdc++.h>
using namespace std;
const long long N = 1000;
long long used[N], a[N];
signed main() {
  srand(123);
  long long cur = 1, cnt = 0;
  while (cur < 256) {
    while (used[cur]) cur++;
    for (long long i = cur + 1; i < N; i++)
      if ((cur ^ i) < N && !used[i] && !used[cur ^ i]) {
        cnt++;
        a[cnt] = cur;
        cnt++;
        a[cnt] = i;
        cnt++;
        a[cnt] = (cur ^ i);
        used[cur] = used[i] = used[cur ^ i] = 1;
        break;
      }
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long nn = n;
    if (n <= 3) {
      cout << n << "\n";
      continue;
    }
    long long x = 1, lg = 0;
    while (x * 4 <= n) x *= 4, lg++;
    n -= (x - 1);
    n--;
    long long id = n / 3;
    long long f[3];
    f[0] = id + x;
    f[1] = 2;
    while (lg > 0) {
      long long t = (1ll << (2 * lg - 2));
      if (id / t == 0) f[1] <<= 2;
      if (id / t == 1) f[1] <<= 2, f[1] |= 2;
      if (id / t == 2) f[1] <<= 2, f[1] |= 3;
      if (id / t == 3) f[1] <<= 2, f[1] |= 1;
      id %= t;
      lg--;
    }
    f[2] = (f[0] ^ f[1]);
    cout << f[n % 3] << "\n";
  }
  return 0;
}
