"You must lift the dam. With a lever. I will give it to you.

You must block the canal. With a rock. I will not give the rock to you." 

Danik urgently needs rock and lever! Obviously, the easiest way to get these things is to ask Hermit Lizard for them.

Hermit Lizard agreed to give Danik the lever. But to get a stone, Danik needs to solve the following task.

You are given a positive integer n, and an array a of positive integers. The task is to calculate the number of such pairs (i,j) that i<j and a_i \& a_j ≥ a_i ⊕ a_j, where \& denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND), and ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).

Danik has solved this task. But can you solve it?

Input

Each test contains multiple test cases.

The first line contains one positive integer t (1 ≤ t ≤ 10) denoting the number of test cases. Description of the test cases follows.

The first line of each test case contains one positive integer n (1 ≤ n ≤ 10^5) — length of the array.

The second line contains n positive integers a_i (1 ≤ a_i ≤ 10^9) — elements of the array.

It is guaranteed that the sum of n over all test cases does not exceed 10^5.

Output

For every test case print one non-negative integer — the answer to the problem.

Example

Input


5
5
1 4 3 7 10
3
1 1 1
4
6 2 5 3
2
2 4
1
1


Output


1
3
2
0
0

Note

In the first test case there is only one pair: (4,7): for it 4 \& 7 = 4, and 4 ⊕ 7 = 3.

In the second test case all pairs are good.

In the third test case there are two pairs: (6,5) and (2,3).

In the fourth test case there are no good pairs.
//JAI BAJRANGBALI                                                                                                                                               
import java.util.*;
import java.io.*;
import java.math.BigInteger;
//class Main    //AtCoder
//class Solution // Codechef
public class Solution //Codeforces
{
    public final static int d = 256;
    static int MOD = 1000000007;
    static final float EPSILON = (float)0.01;
    static final double PI = Math.PI;
    private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
    private static BufferedWriter out = new BufferedWriter (new OutputStreamWriter (System.out));
    static class Graph {
        int V;
        LinkedList<Integer>[] adjListArray;
        Graph(int V) {
            this.V = V;
            adjListArray = new LinkedList[V];
            for(int i = 0; i < V ; i++){
                adjListArray[i] = new LinkedList<Integer>();
            }
        }
        void addEdge( int src, int dest) {
            adjListArray[src].add(dest);
            adjListArray[dest].add(src);
        }

        void DFSUtil(int v, boolean[] visited) {
            visited[v] = true;
            for (int x : adjListArray[v]) {
                if(!visited[x]) DFSUtil(x,visited);
            }

        }
        int connectedComponents() {
            boolean[] visited = new boolean[V];
            int cnt = 0;
            for(int v = 0; v < V; ++v) {
                if(!visited[v] && adjListArray[v].size() != 0) {
                    DFSUtil(v,visited);
                    cnt++;
                }
            }
            return cnt;
        }
    }
    static class SegmentTree{
        int arr[] , st[];
        int maxSize , N;
        SegmentTree(int arr[] , int N){
            this.arr = arr;
            this.N = N;
            int x = (int) (Math.ceil(Math.log(N) / Math.log(2)));
            this.maxSize = 2 * (int) Math.pow(2, x) - 1;
            this.st = new int[maxSize];
            constructST(0 , N-1 , 0);
        }
        void constructST(int start , int end , int ind)
        {
            constructSTUtil(start , end , ind);
        }
        int constructSTUtil(int start , int end , int ind)
        {

            if(start == end){
                st[ind] = arr[start];
                return st[ind];
            }
            else{
                int mid = start + (end - start)/2;
                st[ind] = constructSTUtil(start , mid , (2*ind) + 1) ^ constructSTUtil(mid+1 , end , (2*ind) + 2);
                return st[ind];
            }
        }
        int findXorInRange(int start , int end , int qstart , int qend , int index)
        {
            if(qstart <= start && qend >= end)
            {
                return st[index];
            }
            else if(qstart > end || qend < start || end < start){
                return 0;
            }
            else{
                int mid = start + (end - start)/2;
                return findXorInRange(start , mid , qstart , qend , (2*index) + 1) ^ findXorInRange(mid+1 , end , qstart , qend , (2*index) + 2);
            }
        }
    }
    static class FastReader    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    static class Cell{
        int X , Y , dis;
        Cell(int x , int y , int di){
            X = x;
            Y = y;
            dis = di;
        }
    }
    static boolean isValid(int x , int y , int N , int M){
        return ((x >= 0 && x < N) &&(y >= 0 && y < M));
    }
    static int searchRabinKarp(String pat, String txt)    {
        int M = pat.length();
        int N = txt.length();
        int i, j;
        int p = 0; // hash value for pattern 
        int t = 0; // hash value for txt 
        int h = 1 , cnt = 0;
        int q = 3355439;
        for (i = 0; i < M-1; i++)
            h = (h*d)%q;
        for (i = 0; i < M; i++)
        {
            p = (d*p + pat.charAt(i))%q;
            t = (d*t + txt.charAt(i))%q;
        }
        for (i = 0; i <= N - M; i++)
        {
            if ( p == t )
            {
                for (j = 0; j < M; j++)
                {
                    if (txt.charAt(i+j) != pat.charAt(j))
                        break;
                }
                if (j == M)
                {//System.out.println("Pattern found at index " + i);
                    cnt++;
                }
            }
            if ( i < N-M )
            {
                t = (d*(t - txt.charAt(i)*h) + txt.charAt(i+M))%q;
                if (t < 0)
                    t = (t + q);
            }
        }
        return cnt;
    }
    static long gcd(long bigger , long smaller)    {
        if (smaller == 0)
            return bigger;
        return gcd(smaller, bigger % smaller);
    }
    static long lcm(long a, long b)
    {
        return (a*b)/gcd(a, b);
    }
    static long sumOfArray(long arr[])    {
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++)
            sum += arr[i];
        return sum;
    }
    static boolean isPrime(long n) {
        if(n == 2)
            return true;
        else if(n == 1)
            return false;
        else if (n%2==0)
            return false;
        for(long i=3;i<=Math.sqrt(n);i+=2) {
            if(n%i==0)
                return false;
        }
        return true;
    }
    static long modularExpo(long x, long y, long p)    {
        long res = 1;
        x = x % p;
        if (x == 0) return 0;
        while (y > 0)
        {
            if((y & 1)==1)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }
    static long countDigit(long n)
    {
        return (long)Math.floor(Math.log10(n) + 1);
    }
    static long sumOfDigits(long n)    {
        long sum;
        for (sum = 0; n > 0; sum += n % 10,n /= 10);
        return sum;
    }
    static boolean isPalindrome(String str)    {
        int i = 0, j = str.length() - 1;
        while (i < j) {
            if (str.charAt(i) != str.charAt(j))
                return false;
            i++;
            j--;
        }
        return true;
    }
    static long myLeftShift(long a)
    {
        long cnt = 0;
        while(a != 0)
        {
            a = a/2;
            cnt++;
        }
        return  cnt;
    }
    public static void main(String args[])
    {
        try{
            FastReader sc = new FastReader();
            int T = sc.nextInt();
            while(T-- > 0)
            {
                int N = sc.nextInt();
                long arr[] = new long[N];
                for(int i = 0; i<N;i++)
                    arr[i]=sc.nextLong();
                solve(arr , N);
            }
            try{
                out.flush();
            }catch(Exception e){
                System.out.print(e);
            };
        }
        catch(Exception e){
            System.out.print(e);
        }
    }
    public static void solve(long arr[] , int N)
    {
        try{
            HashMap<Long , Long> hmp = new HashMap<>();
            for(int i = 0 ; i < arr.length ; i++){
                long lbit = myLeftShift(arr[i]);
                try{
                    long hehe = hmp.get(lbit);
                    hmp.put(lbit , hehe+1);
                }catch(Exception e){
                    hmp.put(lbit , 1l);
                }
            }
            long ans = 0;
            for(long key : hmp.keySet()){
                long gg = hmp.get(key);
                ans += (gg * (gg - 1))/2;
            }
            System.out.println(ans);
        }catch(Exception e){
            System.out.println(e);
        }
    }
}