#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int t;
ll n;
ll a, b, c;
void f(ll n, int k) {
  a *= 4;
  b *= 4;
  c *= 4;
  switch (n % 4) {
    case 0:
      break;
    case 1:
      a += 1;
      b += 2;
      c += 3;
      break;
    case 2:
      a += 2;
      b += 3;
      c += 1;
      break;
    case 3:
      a += 3;
      b += 1;
      c += 2;
      break;
  }
  n /= 4;
  k--;
}
int main() {
  cin >> t;
  for (int tt = 0; tt < t; tt++) {
    cin >> n;
    a = 1;
    b = 2;
    c = 3;
    int mn = n % 3;
    n = (n + 2) / 3;
    ll x = 1;
    int k = 0;
    while (n > x) {
      n -= x;
      x *= 4;
      k++;
    }
    x /= 4;
    n--;
    while (k) {
      a *= 4;
      b *= 4;
      c *= 4;
      switch (n / x) {
        case 0:
          break;
        case 1:
          a += 1;
          b += 2;
          c += 3;
          break;
        case 2:
          a += 2;
          b += 3;
          c += 1;
          break;
        case 3:
          a += 3;
          b += 1;
          c += 2;
          break;
      }
      n = n % x;
      k--;
      x /= 4;
    }
    switch (mn) {
      case 0:
        cout << c << endl;
        break;
      case 1:
        cout << a << endl;
        break;
      case 2:
        cout << b << endl;
    }
  }
  return 0;
}
