"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 \ge a_i \oplus a_j$, where $\&$ denotes the bitwise AND operation, and $\oplus$ denotes the bitwise XOR operation.

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 \le t \le 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 \le n \le 10^5$) — length of the array.

The second line contains $n$ positive integers $a_i$ ($1 \le a_i \le 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 \oplus 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.

Difficulty: interview

Starter code:

Solutions:
t = int(input())

for _ in range(t):
    n = int(input())
    
    a = list(map(int, input().split()))
    
    counts = [0] * 32
    for x in a:
        counts[len(bin(x))-2] += 1
        
    total = 0
    for count in counts:
        total += count * (count-1) // 2
    print(total)


import sys
input=sys.stdin.readline
t=int(input())
for you in range(t):
    n=int(input())
    l=input().split()
    li=[int(i) for i in l]
    hashi=dict()
    count=0
    for i in li:
        for j in range(31,-1,-1):
            if(i&(1<<j)):
                ans=j
                break
        if(ans in hashi):
            count+=hashi[ans]
            hashi[ans]+=1
        else:
            hashi[ans]=1
    print(count)


import sys
input = sys.stdin.readline

t=int(input())

for tests in range(t):
    n=int(input())
    A=list(map(int,input().split()))

    X=[0]*32

    for a in A:
        for j in range(32,-1,-1):
            if a & (1<<j) != 0:
                X[j]+=1
                break

    ANS=0

    for x in X:
        ANS+=x*(x-1)//2

    print(ANS)

    


import sys
input = sys.stdin.readline
from bisect import bisect_right

bin_s = [1]
while bin_s[-1] <= 10 ** 9:
    bin_s.append(bin_s[-1] * 2)


def main():
    n = int(input())
    alst = list(map(int, input().split()))
    cnt = [0 for _ in range(35)]
    for a in alst:
        pos = bisect_right(bin_s, a)
        cnt[pos] += 1
    ans = 0
    for num in cnt:
        ans += num * (num - 1) // 2
    print(ans)

for _ in range(int(input())):
    main()

import math
import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int,input().split()))
	group = [0]*31
	for i in a:
		x = int(math.log2(i))
		group[x] += 1
	ans = 0
	for i in group:
		ans += ((i)*(i-1))//2
	print (ans)


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
import sys
input=sys.stdin.readline
def inp():
    return int(input())
def st():
    return input().rstrip('\n')
def lis():
    return list(map(int,input().split()))
def ma():
    return list(map(int,input().split()))
t=int(input())
while(t):
    t-=1
    n=inp()
    a=lis()
    b=[0]*30
    for i in a:
        z=bin(i)[2:]
        z=z.zfill(30)
        for j in range(30):
            if(z[j]=='1'):
                b[j]+=1
                break
    s=0
    for i in b:
        s+=(i*(i-1))//2
    print(s)
    


for t in range(int(input())):
    n=int(input())
    x=list(map(int,input().split()))
    d=dict()
    for i in range(39):
        d[i]=0
    for i in x:
        num=len(str(bin(i)))
        d[num]+=1
    ans=0
    for s in d:
        ans+=(d[s]*(d[s]-1)//2)
    print(ans)

# Python template 
from collections import defaultdict 
import sys
import math 	

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()

def f(n):
	cnt = 0
	while(n):
		n = n//2
		cnt+=1
	return cnt 


for _ in range(int(input())):
	n  = int(input())
	a = get_array()

	d = defaultdict(int)
	
	for i in range(n):
		d[f(a[i])]+=1
	
	ans = 0
	for i in list(d.values()):
		ans += (i*(i-1))//2
	print(ans)


for _ in range(int(input())):
    n = int(input())
    # s = input()
    # n,m = map(int,input().split())
    ar = list(map(int,input().split()))
    ar.sort()
    ans = 0
    t = []
    for i in range(n):
        t.append(len(bin(ar[i])[2:]))
    i = 0
    last = 0 
    count = 0 
    while i<n:
        if last==t[i]:
            count += 1
        else:
            ans += (count*(count+1))//2
            last = t[i]
            count = 0
        i += 1
    ans += (count*(count+1))//2
    # print(t)
    print(ans)