"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.
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    static class Pair{
        int key;
        long value;

        Pair(int key,long value)
        {
            this.key=key;
            this.value=value;
        }
    }
        public static class SortbyKey implements Comparator<Pair>
        {
            public int compare(Pair a, Pair b){
            return (a.key- b.key); 
        }
       }
    static long  highestPowerof2(long n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    long res = 1; 
  
    // Try all powers  
    // starting from 2^1 
    for (long i = 0; i < 8 * Integer.BYTES; i++) 
    { 
        int curr = 1 << i; 
  
        // If current power is  
        // more than n, break 
        if (curr > n) 
        break; 
  
        res = curr; 
    } 
  
    return res; 
} 
  
   
    public static void process()throws IOException
    {
        int n=ni();
        int c=0;
        ArrayList<Long> arr=new ArrayList<Long>();
        ArrayList<Long> max=new ArrayList<Long>();
        for(int i=0;i<n;i++)
            {
                long x=nl();
                arr.add(x);
                max.add(highestPowerof2(x));
            }
        HashMap<Long,Long> hm=new HashMap<Long,Long>();
        for(int i=0;i<n;i++)
        {
            if(!hm.containsKey(max.get(i)))
                hm.put(max.get(i),1l);
            else
                hm.put(max.get(i),hm.get(max.get(i))+1);
        }
        long ans=0l;
        Set<Map.Entry<Long,Long>> st=hm.entrySet();
        for(Map.Entry<Long,Long> me:st)
        {
            long p=me.getValue();
            ans+=(p*(long)(p-1)/2);
        }
        pn(ans);
    }
    
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;
         //PrintWriter out=new PrintWriter("output");
        //oj = System.getProperty("ONLINE_JUDGE") != null;
        //if(!oj) sc=new AnotherReader(100);
 
      //int i=1;
    int T=ni(); while(T-->0)
      //{
        //p("Case #"+i+": ");
            process();
            //i++;
      //}
        long s = System.currentTimeMillis();
      
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }
    static void sort(long arr[],int n)
    {
    shuffle(arr,n);
    Arrays.sort(arr);
    }
    static void shuffle(long arr[],int n)
    {
        Random r=new Random();
        for(int i=0;i<n;i++)
        {
          long temp=arr[i];
          int pos=i+r.nextInt(n-i);
          arr[i]=arr[pos];
          arr[pos]=temp;
        }
    }
 
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static String nn()throws IOException{return sc.next();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static int[] iarr(int N)throws IOException{int[]ARR=new int[N];for(int i=0;i<N;i++){ARR[i]=ni();}return ARR;}
    static long[] larr(int N)throws IOException{long[]ARR=new long[N];for(int i=0;i<N;i++){ARR[i]=nl();}return ARR;}
    static boolean multipleTC=false;
            
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}

    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}