GCD vs. XOR

아직 제출이 없습니다시간 제한20초메모리 제한512 MB

문제

Optimizing is fun! Especially when it's not exactly required.

Everyone knows that bit operations (e.g. bitwise XOR) are faster than recursive functions (such as the greatest common divisor, GCD). To impress your internship supervisors you replaced, in the company's flagship project, all instances of gcd(x,y)\mathop{gcd}(x,y) with much quicker xor(x,y)\mathop{xor}(x,y).

That was yesterday, on Friday. Now you start thinking whether you should have tested your new code before deploying to production... Well, better late than never. Given a sequence of numbers a_1,,a_na\_1, \ldots, a\_n, determine how many pairs (i,j)(i, j) (1i<jn1 \leq i < j \leq n) actually satisfy gcd(a_i,a_j)=xor(a_i,a_j)\mathop{gcd}(a\_i, a\_j) = \mathop{xor}(a\_i, a\_j). Recall that gcd(x,y)\mathop{gcd}(x,y) denotes the greatest common divisor of xx and yy, while xor(x,y)\mathop{xor}(x,y) is the bitwise-XOR operation on xx and yy.

입력

The first line of input contains the number of test cases zz (1z201 \leq z \leq 20). The descriptions of the test cases follow.

The first line of a test case contains an integer nn (1n2,000,0001 \leq n \leq 2\\,000\\,000). The second line contains integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n, all positive and not exceeding 1,000,0001\\,000\\,000.

The total length of all sequences over all test cases does not exceed 31073 \cdot 10^7.

출력

For each test case output a single integer: the number of pairs (a_i,a_j)(a\_i, a\_j) with i<ji < j satisfying gcd(a_i,a_j)=xor(a_i,a_j)\mathop{gcd}(a\_i, a\_j) = \mathop{xor}(a\_i, a\_j).