Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.

Bitsetbaba Ashiq works in a power grid, which consists of $2^{K}$ power stations (numbered $0$ through $2^{K}-1$). Initially, there are no connections between the power stations.

One day, Ashiq's boss gave him $M$ integers $x_{1}, x_{2}, \ldots, x_{M}$ and asked Ashiq to add connections between some power stations. For each two different power stations $u$ and $v$, Ashiq should connect them directly if there is a valid index $i$ such that $u \oplus v = x_{i}$. Here, $\oplus$ denotes the bitwise XOR operation.

To confirm whether Ashiq has completed the task correctly, he should report to his boss the number of connected components in the resulting power grid. Two power stations $u$ and $v$ are in the same connected component if they are connected directly or indirectly (through other stations).

Ashiq is lazy and he does not want to actually physically perform the task, but he also wants to keep his job. Therefore, he asks for your help. Can you help him find the final number of connected components?

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains two space-separated integers $K$ and $M$.
The second line contains $M$ space-separated integers $x_{1}, x_{2}, \ldots, x_{M}$.

------  Output ------
For each test case, print a single line containing one integer — the number of connected components.

------  Constraints  ------
$1 ≤ T ≤ 10^{5}$
$1 ≤ K ≤ 30$ 
$1 ≤ M ≤ 10^{5}$
$0 ≤ x_{i} < 2^{K}$ for each valid $i$
the sum of $M$ over all test cases does not exceed $10^{5}$

----- Sample Input 1 ------ 
2

2 1

0

2 1

2
----- Sample Output 1 ------ 
4

2
----- explanation 1 ------ 
Example case 1: There are four connected components; each of them contains one of the four nodes.

Example case 2: There are two connections — one between nodes $0$ and $2$ and the other between nodes $1$ and $3$. Thus, there are two connected components.

Source: codechef | Difficulty: VERY_HARD
Tags: Matrices

Mathematics


Solutions:
T = int(input())
for i in range(0, T):
	(K, M) = map(int, input().split())
	s = [int(x) for x in input().split()]
	arr = [0] * 32
	c = 0
	for j in range(0, len(s)):
		for k in range(0, len(arr)):
			if arr[k] == 0:
				arr[k] = s[j]
				s[j] = 0
			else:
				s[j] = min(s[j], s[j] ^ arr[k])
	for j in range(0, len(arr)):
		if arr[j] > 0:
			c = c + 1
	print(2 ** K // 2 ** c)