#include <bits/stdc++.h>
using namespace std;
int arr[100001];
int main() {
  int t;
  cin >> t;
  for (int _ = 0; _ < t; _++) {
    long long n;
    cin >> n;
    n--;
    long long curr = 1;
    long long total = 0;
    long long iters = 0;
    while (total <= n / 3) {
      total += curr;
      curr *= 4;
    }
    curr /= 4;
    long long base = curr << 1;
    long long num = n / 3 - total + curr;
    long long exp = 1;
    long long first = n / 3 - total + 2 * curr;
    while (num > 0) {
      if (num % 4 == 1) base += exp * 2;
      if (num % 4 == 2) base += exp * 3;
      if (num % 4 == 3) base += exp * 1;
      exp *= 4;
      num /= 4;
    }
    if (n % 3 == 0) {
      cout << first << endl;
    } else if (n % 3 == 1) {
      cout << base << endl;
    } else {
      cout << (first ^ base) << endl;
    }
  }
}
