#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, unsigned long long int y,
                    long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int pow4;
    for (long long int i = 0; i < 32; i++) {
      if (n < power(4, i, LLONG_MAX)) {
        pow4 = i - 1;
        break;
      }
    }
    n -= power(4, pow4, LLONG_MAX);
    long long int a = power(4, pow4, LLONG_MAX);
    a += n / 3;
    string a_bin, b_bin = "10", c_bin = "11";
    long long int temp = a;
    while (temp > 0) {
      a_bin.push_back(temp % 2 + '0');
      temp /= 2;
    }
    reverse(a_bin.begin(), a_bin.end());
    for (long long int i = 1; i < a_bin.length(); i++) {
      string s = a_bin.substr(i, 2);
      if (s == "00") {
        b_bin += "00";
        c_bin += "00";
      }
      if (s == "01") {
        b_bin += "10";
        c_bin += "11";
      }
      if (s == "10") {
        b_bin += "11";
        c_bin += "01";
      }
      if (s == "11") {
        b_bin += "01";
        c_bin += "10";
      }
      i++;
    }
    if (n % 3 == 0)
      cout << a << "\n";
    else if (n % 3 == 1)
      cout << stoll(b_bin, NULL, 2) << "\n";
    else
      cout << stoll(c_bin, NULL, 2) << "\n";
  }
  return 0;
}
