A. Find Pairs

5

1 votes
Problem

Given a positive integer n and an array a of size n, find the no of pairs (i, j) such that i < j  and ai & aj aI aj ,  where & denotes the bitwise AND operation, and ⊕ denotes the bitwise XOR operation.

Input:

First line contains one integer t (1 ≤ t ≤ 10) – no of test cases.

First line of each test case contains an integer n (1 ≤ n ≤ 100000).

Second line of each test case contains n integers ai (1 ≤ ai ≤ 109) of the array a.

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

Output:

For every test case output one integer denoting no of such pairs.

Time Limit: 0.5
Memory Limit: 256
Source Limit:
Editor Image

?