XOR and AND

 Alice has an array 

of length . She is interested in finding the number of pairs such that and

.

represents the Bitwise XOR operator.

represents the Bitwise AND operator.

Input Format

  • The first line of input will contain an integer
  • — number of test cases. Then the test cases follow.
  • Each test case contains two lines of input.
  • The first line of each test case contains an integer
  • , the length of the array
  • .
  • The second line of each test case contains
  • space-separated integers
    • .

    Output Format

    For each test case, output the number of pairs

    such that and

    .

    Constraints

  • Sum of
  • over all test cases does not exceed
    • .

    Sample Input 1

    2
    4
    1 1 2 3
    4
    1 2 3 4
    

    Sample Output 1

    2
    1
    

    Explanation

    Test case

    : The two pairs of indices satisfying the condition are and

    , because

    and
  • and

    Test case

    : The only pair of indices satisfying the condition is .
    Previous
    Next Post »