#include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
T abs(T x) {
  return x < 0 ? -x : x;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
bool chmin(T& x, const T& y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template <typename T>
bool chmax(T& x, const T& y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}
string to_bin(int x) {
  string ret;
  while (x) {
    ret = ret + (char)((x % 2) + '0');
    x /= 2;
  }
  return ret;
}
int main(int, char**) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long m = (n - 1) / 3;
    int k = 0;
    long long p = 1;
    while (m >= p) {
      m -= p;
      k += 1;
      p *= 4;
    }
    vector<long long> a;
    for (int i = 0; i < k; ++i) {
      a.push_back(m % 4);
      m /= 4;
    }
    long long A, B;
    A = 1LL << (2 * k);
    B = 1LL << (2 * k + 1);
    vector<long long> b = {0, 2, 3, 1};
    for (int i = 0; i < k; ++i) {
      A ^= a[i] << (2 * i);
      B ^= b[a[i]] << (2 * i);
    }
    long long C = A ^ B;
    long long ans;
    if (n % 3 == 1) {
      ans = A;
    } else if (n % 3 == 2) {
      ans = B;
    } else {
      ans = C;
    }
    cout << ans << "\n";
  }
  cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec"
       << endl;
  return 0;
}
