"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.io.*;
import java.text.DecimalFormat;
import java.util.*;
    public class main2 {
    	static ArrayList<pair> factors;
    	static boolean isComposite[];
    	static ArrayList<Integer> primes;
    	public static boolean isprime(long n){
    		if(n<=10001){
    			return !isComposite[(int)n];
    		}
    		for(int i=0;i<primes.size();i++){
    			if(primes.get(i)*primes.get(i)*1l>n){
    				break;
    			}
    			if(n%primes.get(i)==0){
    				return false;
    			}
    			
    		}
    		return true;
    	}
    	static int[] res;
    	
    	public static void sieve(int n){
    		isComposite=new boolean[n+1];
    		primes =new ArrayList<Integer>();
    		isComposite[0]=true;
    		isComposite[1]=true;
    		for(int i=2;i<=n;i++){
    			if(!isComposite[i]){
    				for(int j=2*i;j<=n;j=j+i){
    					isComposite[j]=true;
    				}
    			}
    			primes.add(i);
    		}
    		
    	}
    	public static void primefactors(long n){
    		 factors=new ArrayList<pair>();
    		for(int x:primes){
    			if(x*x*1l>n){
    				break;
    			}
    		
    			
    			if(n%x==0){
    				
    					pair p=new pair(x,0);
    					 factors.add(p);
    				while(n%x==0){
    				n/=x;
    				p.y++;}
    				
    			}
    		}
    		if(n!=1){
    			factors.add(new pair((int)n,1));
    		}
    		
    	}
    	public static long powfact(long n,long p){
    		int res=0;
    		for(long i=p;i*1l<=n;i=i*p*1l){
    			res+=(n/i);
    		}
    		return res;
    	}
    	
    	public static long GCD(long i, long j){
    	if (i==0){
    		return j;
    	}
    	return GCD(j%i,i);
    	}
    	public static long LCM(long i, long j){
    		return(i*j)/GCD(i,j);
    	}
     static long[][] dp;
     static int[] a;
     static int n;
     public static long solve(int i,int o){
    	 if(i==n){
    		 return 0;
    	 }
    	 if(dp[i][o]!=-1){
    		 return dp[i][o];
    	 }
    	 long t,l;
    	 if(o==1){
    		  t=a[i]+solve(i+1,0);
    		  l=solve(i+1,1);}
    	 else{
    	      t=-a[i]+solve(i+1,1);
    		  l=solve(i+1,0);
    	 }
    	 return dp[i][o]=Math.max(t, l);
     }
     public static void swap(int i,int j){
    	 int temp=a[i];
    	 a[i]=a[j];
    	 a[j]=temp;
    	
     }
    	public static void main(String[] args) throws Exception {
    	Scanner sc=new Scanner(System.in);
    	int t=sc.nextInt();
    	
    	while(t-->0){
int []pow=new int[65];
int n=sc.nextInt();
long []a=new long[n];
for(int i=0;i<n;i++){
	a[i]=sc.nextLong();
	pow[p(a[i])]++;
}
long ans=0;
for(int i=0;i<65;i++){
	if(pow[i]>1){
	ans+=(pow[i]*1l*(pow[i]-1)/2);}
}
System.out.println(ans);

    	}
   
   
     
  
    }
    	public static int p(long x){
    		int t=0;
    		while(x>1){
    			t++;
    			x=x/2;
    		}
    		return t;
    	}
     static long[] fact;
     public static long fact(int x){
long y=(int)Math.pow(2,x)-1;
return((y+1)*(y/2)+(y/2+1));
}     
    	
    	
    	static ArrayList<Integer > [] adjlist;
    	static int [] leaves;
    	static PriorityQueue<pair> centroid;
    	
    	public static void dfs1(int u,int p){
    		leaves[u]=1;
    		if(adjlist[u].size()==1&&u!=0){
    			
    			return;
    		}
    		for( int x:adjlist[u]){
    			if(x!=p){
    				dfs1(x,u);
    				leaves[u]+=leaves[x];
    			}
    		}
    	}
    	public static void dfs(int u,int p){
    		if(adjlist[u].size()==1&&u!=0){
    			centroid.add(new pair(n-1,u));
    			return;
    		}
    		int ans=n-leaves[u];
    		for(int x:adjlist[u]){
    			if(x!=p){
    			ans=Math.max(ans, leaves[x]);
    			dfs(x,u);
    			
    			}
    		}
    		centroid.add(new pair(ans,u));
    		}
    	
    	static class pair implements Comparable<pair>{
    		int x;
    		int y;
    		public pair(int x, int y){
    			this.x=x;
    					this.y=y;
    		}
			@Override
			public int compareTo(pair o) {
				// TODO Auto-generated method stub
				return x-o.x;
			}
    	}
    	
    	  	 	static class SegmentTree{
    	   	 		int[] arr , sTree;
    	   	 	static	int N;
    	   	 		public SegmentTree(int[] in){
    	   	 			arr=in;
    	   	 		N=arr.length-1;
    	   	 			sTree=new int[2*N];
    	   	 			
    	   	 			build(1,1,N);
    	   	 		}
    	   	 		public void build(int node, int l, int r){
    	   	 			if(l==r){
    	   	 				sTree[node]=arr[l];
    	   	 			}
    	   	 			else{
    	   	 				int leftchild=node*2;
    	   	 				int rightchild=node*2+1;
    	   	 				int mid =(l+r)/2;
    	   	 				build(leftchild,l,mid);
    	   	 				build(rightchild,mid+1,r);
    	   	 				sTree[node]=sTree[leftchild]&sTree[rightchild];
    	   	 			}
    	   	 		}
    	   	 		public  void update(int i, int val){
    	   	 			int node =i+N-1;
    	   	 			arr[i]=val;
    	   	 			sTree[node]=val;
    	   	 			node=node/2;
    	   	 			while(node>0){
    	   	 			int leftchild=node *2;
       	 				int rightchild=node*2+1;
       	 			sTree[node]=sTree[leftchild]&sTree[rightchild];
       	 			node=node/2;
    	   	 			}
    	   	 			return;
    	   	 			
    	   	 		}
    	   	 		public int query(int i, int j){
    	   	 			 return query(1,1, N,  i, j);
    	   	 		}
    	   	 		public int query(int node,int l, int r, int i , int j){
    	   	 			if(i>r||j<l){
    	   	 				return 1<<30;
    	   	 			}
    	   	 			if(i<=l&&r<=j){
    	   	 				return sTree[node];
    	   	 			}
    	   	 		int leftchild=node*2;
    	 				int rightchild=node*2+1;
    	 				int mid =(l+r)/2;
    	 				
    	 			return	query(leftchild,l,mid,i,j)&query(rightchild,mid+1,r,i,j);
    	 				
    	   	 		}
    	   	 	}
     
     
    	static class Scanner {
    		StringTokenizer st;
    		BufferedReader br;
     
    		public Scanner(InputStream s) {
    			br = new BufferedReader(new InputStreamReader(s));
    		}
     
    		public boolean hasNext() {
    			// TODO Auto-generated method stub
    			return false;
    		}
     
    		public String next() throws IOException {
    			while (st == null || !st.hasMoreTokens())
    				st = new StringTokenizer(br.readLine());
    			return st.nextToken();
    		}
     
    		public int nextInt() throws IOException {
    			return Integer.parseInt(next());
    		}
     
    		public long nextLong() throws IOException {
    			return Long.parseLong(next());
    		}
     
    		public String nextLine() throws IOException {
    			return br.readLine();
    		}
     
    		public double nextDouble() throws IOException {
    			String x = next();
    			StringBuilder sb = new StringBuilder("0");
    			double res = 0, f = 1;
    			boolean dec = false, neg = false;
    			int start = 0;
    			if (x.charAt(0) == '-') {
    				neg = true;
    				start++;
    			}
    			for (int i = start; i < x.length(); i++)
    				if (x.charAt(i) == '.') {
    					res = Long.parseLong(sb.toString());
    					sb = new StringBuilder("0");
    					dec = true;
    				} else {
    					sb.append(x.charAt(i));
    					if (dec)
    						f *= 10;
    				}
    			res += Long.parseLong(sb.toString()) / f;
    			return res * (neg ? -1 : 1);
    		}
     
    		public boolean ready() throws IOException {
    			return br.ready();
    		}
     
    	}}