T = int(input()) for _ in range(T): N, M = map(int, input().split()) A = list(map(int, input().split())) if N <= 2 * M: B = list(A) while len(B) != 1: C = [] for i in range(1, len(B)): C.append((B[i] + B[i-1]) * (B[i-1] + B[i]) % (1 << M)) B = C print(B[0]) continue C = [0] * M for i in range(M): for j in range(i, N - M + i + 1): if (N - M) & (j - i) == j - i and A[j] % 2: C[i] = (C[i] + 1) % 2 D = list(C) for i in range(2, M + 1): E = [] for j in range(1, len(D)): E.append((D[j-1] + D[j]) * (D[j-1] + D[j]) % (1 << i)) D = E print(D[0])