#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n, a, b, x, y;
    cin >> n;
    x = 1 + (n - 1) / 3;
    long long int sum = 0, k = 1;
    while (sum < x) {
      sum += k;
      k <<= 2;
    }
    k >>= 2;
    sum -= k;
    y = a = (x - sum - 1 + k);
    int c[] = {0, 2, 3, 1};
    k = 1, b = 0;
    while (y) {
      b += c[y % 4] * k;
      k <<= 2;
      y >>= 2;
    }
    x = a ^ b;
    if (n % 3 == 1) {
      cout << a << endl;
    } else if (n % 3 == 2) {
      cout << b << endl;
    } else
      cout << x << endl;
  }
  return 0;
}
