#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    n--;
    long long int gr = n / 3 + 1;
    int ind = n % 3;
    long long int x = 3 * gr + 1;
    long long int k = -1;
    while (x) {
      k++;
      x >>= 1;
    }
    long long int one = 1;
    long long int b = k - 2;
    if (k % 2)
      b++;
    else {
      if (3 * gr + 1 != (one << k)) b += 2;
    }
    long long int gr2 = gr - 1 - ((one << b) - 1) / 3;
    long long int ans[3];
    ans[0] = (one << b) + gr2;
    ans[1] = 0;
    long long int beta = ans[0];
    int in = 0;
    while (beta) {
      long long int d = beta % 4;
      if (d) ans[1] += ((d % 3 + 1) << in);
      in += 2;
      beta >>= 2;
    }
    ans[2] = ans[0] ^ ans[1];
    cout << ans[ind] << endl;
  }
}
