"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 ≥ a_i ⊕ a_j, where \& denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND), and ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).

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

The second line contains n positive integers a_i (1 ≤ a_i ≤ 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 ⊕ 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.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	private BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	private BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
	private StringTokenizer st;
	private Long MOD = 1000000007L;

	public static void main(String[] args) throws Exception {
		new Main().solve();
	}

	private void solve() throws Exception {

		int testCases = 1;
		testCases = Integer.parseInt(in.readLine().trim());
		for (int i = 1; i <= testCases; i++) {
			solve(i);
		}

		out.flush();
		out.close();
	}

	private void solve(int testCaseNumber) throws Exception {
		int n = ri();
		
		int arr2[] = ria(n);
		
		String arr[] = new String[n];
		
		for(int i = 0; i < n; i++) {
			arr[i] = str(arr2[n - 1 - i]);
		}
//		System.out.println(Arrays.toString(arr));
		
		long ans = 0;
		
		Node node = new Node();
		
		node = insert(arr[0], node);
		
		for(int i = 1; i < n; i++) {
			// do some wooodo
			
			int index = firstOne(arr[i]);
			
			ans += find(arr[i], index, node);
			
			
			node = insert(arr[i], node);
		}
		
		out.write(ans + "\n");
	}
	
	int firstOne(String s) {
		
		int n = s.length();
		
		for(int i = 0; i < n; i++) {
			if(s.charAt(i) == '1')return i + 1;
		}
		
		return n;
	}
	
	String str(int n ) {
		
		StringBuilder s = new StringBuilder();
		
		for(int i = 0 ; i < 32; i++) {
			int temp = 0;
			if(n % 2 == 1) temp  = 1;
			
			s.append(temp);
			n = n / 2;
		}
		
		
		s.reverse();
		return s.toString();
		
		
	}

	class Node {
		Node[] arr = new Node[2];
		int freq;
	};

	// Function to insert a node in the trie
	Node insert(String s, Node root) {
		int in;
		Node cur = root;
		for (int i = 0; i < s.length(); i++) {
			in = s.charAt(i) - '0';

			// If there is no node created then create one
			if (cur.arr[in] == null)
				cur.arr[in] = new Node();

			// Increase the frequency of the node
			cur.arr[in].freq++;

			// Move to the next node
			cur = cur.arr[in];
		}

		// Return the updated root
		return root;
	}

	// Function to return the count of Strings
	// whose prefix of length k matches with the
	// k length prefix of the given String
	int find(String s, int k, Node root) {
		int in, count = 0;
		Node cur = root;

		// Traverse the String
		for (int i = 0; i < s.length(); i++) {
			in = s.charAt(i) - '0';

			// If there is no node then return 0
			if (cur.arr[in] == null)
				return 0;

			// Else traverse to the required node
			cur = cur.arr[in];

			count++;

			// Return the required count
			if (count == k)
				return cur.freq;
		}
		return 0;
	}

	class GFG {


		// Driver code
		public void mainss(String[] args) {
			String arr[] = { "abba", "abbb", "abbc", "abbd", "abaa", "abca" };
			int n = arr.length;

			Node root = new Node();

			// Insert the Strings in the trie
			for (int i = 0; i < n; i++)
				root = insert(arr[i], root);

			// Query 1
			System.out.print(find("abbg", 3, root) + "\n");

			// Query 2
			System.out.print(find("abg", 2, root) + "\n");

			// Query 3
			System.out.print(find("xyz", 2, root) + "\n");

		}
	}

	public long modInv(long a, long MOD) {
		return new BigInteger(a + "").modPow(new BigInteger((MOD - 2) + ""), new BigInteger(MOD + "")).longValue();
	}

	public long modPro(long a, long b, long MOD) {
		return ((a % MOD) * (b % MOD)) % MOD;
	}

	private long factorialMod(int n, long MOD) {
		long pro = 1;

		for (long i = 1; i <= n; i++) {
			pro = pro * i;
			pro %= MOD;
		}

		return pro;
	}

	// utilities below

	// IO UTILS
	String line() throws IOException {
		return in.readLine();
	}

	StringTokenizer tokens() throws IOException {
		return new StringTokenizer(line());
	}

	long l(String s) {
		return Long.parseLong(s);
	}

	long rl() throws IOException {
		return l(line());
	}

	long[] rla(int n) throws IOException {
		long[] arr = new long[n];
		st = tokens();

		for (int i = 0; i < n; i++)
			arr[i] = l(st.nextToken());

		return arr;
	}

	int i(String s) {
		return Integer.parseInt(s);
	}

	int ri() throws IOException {
		return i(line());
	}

	int[] ria(int n) throws IOException {
		int[] arr = new int[n];
		st = tokens();

		for (int i = 0; i < n; i++)
			arr[i] = i(st.nextToken());

		return arr;
	}

	String rs() throws IOException {
		return line();
	}

	String[] rsa(int n) throws IOException {
		String s[] = new String[n];

		st = tokens();

		for (int i = 0; i < n; i++)
			s[i] = st.nextToken();

		return s;
	}
	// IO UTILS END

	// MATH UTILS

	long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	// MATH UTILS END
}