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, ... 
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rustam Musin (t.me/musin_acm)
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    CPrekrasnieTroiki solver = new CPrekrasnieTroiki();
    solver.solve(1, in, out);
    out.close();
  }

  static class CPrekrasnieTroiki {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int t = in.readInt();
      while (t-- > 0) {
        long n = in.readLong();
        long x = new Solver().solve(n - 1);
        out.printLine(x);
      }
//    List<Integer> res = gen(100);
//    for (int i = 0; i < res.size(); i += 3) {
//      printTriple(res.subList(i, i + 3), out);
//    }

//    for (int i = 1; i <= 200; i++) {
//      long x = new Naive().solve(i);
//      long y = new Solver().solve(i - 1);
//      out.printLine(x == y);
//    }
    }

    class Solver {
      int[] res;
      int[][][] patterns = {
          {
              {0, 0},
              {0, 0},
              {0, 0}
          },
          {
              {0, 1},
              {1, 0},
              {1, 1}
          },
          {
              {1, 0},
              {1, 1},
              {0, 1},
          },
          {
              {1, 1},
              {0, 1},
              {1, 0}
          }
      };

      long solve(long number) {
        int len = 2;
        while (number >= 3 * (1L << (len - 2))) {
          number -= 3 * (1L << (len - 2));
          len += 2;
        }
        res = new int[len];
        int type = (int) (number % 3);
        res[0] = patterns[1][type][0];
        res[1] = patterns[1][type][1];
        dfs(2, number);
        return resToLong();
      }

      long resToLong() {
        long result = 0;
        for (int x : res) result = result * 2 + x;
        return result;
      }

      void dfs(int start, long index) {
        if (start >= res.length) {
          //last item
          return;
        }
        int len = res.length - start;
        long suffixSize = (1L << (len - 2)) * 3;
        for (int i = 0; ; i++) {
          if (index >= suffixSize) {
            index -= suffixSize;
            continue;
          }
          int type = (int) (index % 3);
          res[start] = patterns[i][type][0];
          res[start + 1] = patterns[i][type][1];
          break;
        }
        dfs(start + 2, index);
      }

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(long i) {
      writer.println(i);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public int readInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long readLong() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);

    }

  }
}

