#include <bits/stdc++.h>
using namespace std;
long long fastpower(long long b, long long p) {
  long long k = p % 2 ? b : 1;
  return p == 0 ? 1 : k * (fastpower(b * b, p / 2));
}
int c;
int a[4][3] = {{0, 0, 0}, {1, 2, 3}, {2, 3, 1}, {3, 1, 2}};
long long f(long long k) {
  if (k == -1)
    return c + 1;
  else
    return a[k % 4][c] + 4 * (f(k / 4 - 1));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    n--;
    c = n % 3;
    cout << f(n / 3 - 1) << "\n";
  }
}
