Consider the infinite sequence s of positive integers, created by repeating the following steps:

  1. Find the lexicographically smallest triple of positive integers (a, b, c) such that 
    * a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). 
    * a, b, c are not in s. 
Here triple of integers (a_1, b_1, c_1) is considered to be lexicographically smaller than triple (a_2, b_2, c_2) if sequence [a_1, b_1, c_1] is lexicographically smaller than sequence [a_2, b_2, c_2]. 
  2. Append a, b, c to s in this order. 
  3. Go back to the first step. 



You have integer n. Find the n-th element of s.

You have to answer t independent test cases.

A sequence a is lexicographically smaller than a sequence b if in the first position where a and b differ, the sequence a has a smaller element than the corresponding element in b.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.

Each of the next t lines contains a single integer n (1≤ n ≤ 10^{16}) — the position of the element you want to know.

Output

In each of the t lines, output the answer to the corresponding test case.

Example

Input


9
1
2
3
4
5
6
7
8
9


Output


1
2
3
4
8
12
5
10
15

Note

The first elements of s are 1, 2, 3, 4, 8, 12, 5, 10, 15, ... 
#include <bits/stdc++.h>
using namespace std;
long long int pow1(long long int a, long long int b,
                   long long int m = 1000000007) {
  if (b == 0)
    return 1ll;
  else if (b == 1)
    return a;
  else {
    long long int x = pow1(a, b / 2, m);
    x *= x;
    x %= m;
    if (b % 2) {
      x *= a;
      x %= m;
    }
    return x;
  }
}
template <class avgType>
avgType avg(avgType a, avgType b) {
  return (a + b) / 2;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int randInt() { return rng() % INT_MAX; }
long long int randLL() { return rng64() % LLONG_MAX; }
vector<int> hashmods = {1000000007, 1000000009, 1000000021,
                        1000000033, 1000000087, 1000000093};
int t;
long long int n;
long long int solve(long long int x) {
  if (x <= 4) return x;
  int fl = 0;
  if (x % 3 == 0) {
    x--;
    fl = 1;
  }
  long long int x1 = 1, x2 = 2, curr = 0;
  while (true) {
    curr += (x1 + x2);
    if (curr >= x) break;
    x1 *= 4ll;
    x2 *= 4ll;
  }
  long long int prev = curr - (x1 + x2);
  long long int rem = x - prev;
  long long int div = (x1 + x2) / 4ll;
  long long int quad = rem / div;
  if (rem % div) quad++;
  long long int x11 = x1 / 4ll, x22 = x2 / 4ll;
  long long int quadstr = x2;
  if (quad >= 2) quadstr += x22;
  if (quad >= 3) quadstr += x11;
  if (quad == 4) quadstr -= x22;
  if (x % 3 == 1) {
    return (x1 + (x - prev) / 3);
  } else {
    long long int qd = quad, rem1 = rem, ans = quadstr, iter = 0;
    while (x11 > 1) {
      long long int within = rem1 - (qd - 1) * x11 * 3ll;
      long long int div1 = (x11 + x22) / 4ll;
      long long int qd1 = within / div1;
      if (within % div1) qd1++;
      x11 /= 4;
      x22 /= 4;
      if (qd1 == 2)
        ans += x22;
      else if (qd1 == 3)
        ans += (x22 + x11);
      else if (qd1 == 4)
        ans += (x11);
      qd = qd1;
      rem1 = within;
    }
    rem1 = rem1 - (qd - 1) * x11 * 3;
    if (x11 == 1) {
      if (rem1 == 5)
        ans += 2;
      else if (rem1 == 8)
        ans += 3;
      else if (rem1 == 11)
        ans += 1;
    }
    if (fl == 0)
      return ans;
    else {
      return ans ^ (x1 + ((x - 1) - prev) / 3);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << solve(n) << "\n";
  }
  return 0;
}
