#include <bits/stdc++.h>
using namespace std;
int t;
long long n;
long long ans;
long long switchbit(int x) {
  if (x == 0) return 0;
  if (x == 1) return 2;
  if (x == 2) return 3;
  if (x == 3) return 1;
  return 0;
}
void solve(long long x) {
  long long base = 1;
  while (x >= base) base = base * 4;
  long long prebase = base / 4;
  long long x2 = x - prebase + 1;
  if (x2 % 3 == 1) {
    ans = prebase + x2 / 3;
    return;
  } else if (x2 % 3 == 2) {
    x2 = x2 / 3;
    ans = 0;
    long long tt = 1;
    while (x2 > 0) {
      ans += (switchbit(x2 % 4)) * tt;
      tt *= 4;
      x2 /= 4;
    }
    ans += prebase * 2;
    return;
  } else {
    solve(x - 2);
    long long pre1 = ans;
    solve(x - 1);
    long long pre2 = ans;
    ans = pre1 ^ pre2;
    return;
  }
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%lld", &n);
    solve(n);
    printf("%lld\n", ans);
  }
}
