#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, ans1, ans2, ans3, num, sum, sh, r, q, len, p, r1;
  cin >> t;
  while (t--) {
    cin >> n;
    q = ceil(n / 3.0);
    r = n % 3;
    n = q;
    ans1 = ans2 = 0;
    num = 1;
    sh = 1;
    sum = num;
    while (sum <= n) {
      num = num * 4;
      ++sh;
      sum += num;
    }
    if ((sum - num) == n) --sh;
    ans1 = ((long long)1 << (2 * (sh - 1)));
    ans2 = ((long long)1 << (2 * sh - 1));
    len = (sh - 1) * 2;
    sum = n - (sum - num);
    if (sum == 0) sum = num / 4;
    num = pow(4, len / 2);
    while (len > 0) {
      r1 = ceil(sum / ((num / 4) * 1.0));
      if (r1 == 2) {
        ans1 = ans1 | ((long long)1 << (len - 2));
        ans2 = ans2 | ((long long)2 << (len - 2));
      } else if (r1 == 3) {
        ans1 = ans1 | ((long long)2 << (len - 2));
        ans2 = ans2 | ((long long)3 << (len - 2));
      } else if (r1 == 4) {
        ans1 = ans1 | ((long long)3 << (len - 2));
        ans2 = ans2 | ((long long)1 << (len - 2));
      }
      r1 = sum % (num / 4);
      if (r1 == 0) r1 = num / 4;
      sum = r1;
      len = len - 2;
      num = num / 4;
    }
    ans3 = ans1 ^ ans2;
    if (r == 0)
      cout << ans3 << "\n";
    else if (r == 1)
      cout << ans1 << "\n";
    else
      cout << ans2 << "\n";
  }
  return 0;
}
