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.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;


public class Solution {
    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader(System.in);
        StringBuilder sb = new StringBuilder();
        int i,j;
        /*HashSet<Integer> set=new HashSet<>();
        int n=in.nextInt();
        ArrayList<Integer> list=new ArrayList<>();
        int min=1;
        while(list.size()<=n){
            int x,y,z;
            for(x=1;x<=10000;x++)
                if(!set.contains(x))
                    break;
            for(y=x+1;y<=10000;y++){
                z=x^y;
                if(z>y && !set.contains(y) && !set.contains(z)){
                    set.add(x);
                    set.add(y);
                    set.add(z);
                    list.add(x);
                    list.add(y);
                    list.add(z);
                    break;
                }
            }
        }
        int pow[]=new int[10];
        HashSet<Integer> st=new HashSet<>();
        pow[0]=1;
        st.add(1);
        for(i=1;i<10;i++) {
            pow[i] = pow[i - 1] * 2;
            st.add(pow[i]);
        }
        //System.out.println(list);
        for(i=0;i<n;i++){
            System.out.print(list.get(i)+" ");
            if(st.contains(i+1))
                System.out.println();
        }*/

        int t=in.nextInt();
        while(t-->0){
            long n=in.nextLong();
            if(n==1){
                sb.append("1\n");
                continue;
            }
            long pow2=1;
            while(n>=pow2){
                pow2=pow2*4;
            }
            pow2=pow2/4;
            long rem=(n-pow2)%3;
            long div=(n-pow2)/3;
            long ans1=pow2+div;
            if(rem==0){
                sb.append(ans1).append("\n");
                continue;
            }

            long ans=pow2*2;
            long val[]={0,2,3,1};
            pow2=pow2*4;
            while(div>0){
                while(div<pow2)
                    pow2=pow2/4;

                ans=ans+pow2*val[(int)(div/pow2)];
                div=div%pow2;
            }

            if(rem%2==1)
                sb.append(ans).append("\n");
            else
                sb.append(ans1^ans).append("\n");

        }
        System.out.println(sb);


    }
}
class Node{
    int max;
    boolean even,odd;
    Node(int m,boolean a,boolean b){
        max=m;
        even=a;
        odd=b;
    }
}
class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}




