Polo, the Penguin, likes the XOR operation. Please read NOTE if you are not familiar with XOR operation. 
XOR-sum of a list of numbers is the result of XOR-ing all of them. XOR-sum of (A[1] XOR A[2] XOR ... XOR A[N]) is defined as A[1] XOR (A[2] XOR (A[3] XOR ( ... XOR A[N]))).
He has an array A consisting of N integers. Index in the array are numbered from 1 to N, inclusive. Let us denote by F(L, R), the XOR-sum of all integers in the array A whose indices lie from L to R, inclusive, i.e. F(L, R) = A[L] XOR A[L+1] XOR ... XOR A[R]. Your task is to find the total sum of XOR-sums F(L, R) over all L and R such that 1 ≤ L ≤ R ≤ N.

Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer N denoting the size of A. The second line contains N space-separated integers A[1], A[2], ..., A[N].

Output
For each test case, output a single line containing the total sum to the corresponding test case.

Constraints

1 ≤ T ≤ 100,000
1 ≤ N ≤ 100,000
0 ≤ A[i] ≤ 1,000,000,000 (10^9)
The total sum of all N over all test cases will not exceed 100,000.


Example
Input:
1
2
1 2

Output:
6

Explanation
Example case 1. F(1, 1) = A[1] = 1, F(2, 2) = A[2] = 2 and F(1, 2) = A[1] XOR A[2] = 1 XOR 2 = 3. Hence the answer is 1 + 2 + 3 = 6.


NOTE

XOR operation is a bitwise "Exclusive OR" operation performed on two integers in binary representation. First, the shorter number is prepended with leading zeroes until the numbers have equal size in binary. Then the resulting number (also in binary) contains 0 in all positions where the corresponding bits coincide, and 1 on the rest of the positions.
 For example, 3 XOR 5 = 0112 XOR 1012 = 1102 = 6.
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import random


def count_bits(n):
    res = 0
    while n:
        res += 1
        n >>= 1
    return res


t = int(raw_input())
for _ in range(t):
    n = int(raw_input())
    lst = map(int, raw_input().split())
    #lst = [random.randint(0, (1 << 16) - 1) for i in range(10**5)]

    n_bits = count_bits(max(lst))
    counts = [(0, 0, 0) for _ in range(n_bits)]
    for num in lst:
        for i, (c0, c1, count) in enumerate(counts):
            bit = (num & (1 << i)) >> i
            if bit == 1:
                c0, c1 = c1, c0
                c1 += 1
            else:
                c0 += 1
            count += c1

            counts[i] = c0, c1, count

    result = 0
    for i, (c0, c1, count) in enumerate(counts):
        result += count << i

    print result

'''
count = 0

c0, c1 = 0, 0
for i, bit in enumerate(lst):
    #print c0, c1, "bit", bit, "->",
    if bit == 1:
        c0, c1 = c1, c0
        c1 += 1
    else:
        c0 += 1
    count += c1
    #print c0, c1, "count", count

print count
'''