import itertools as it
N, M = map(int, input().split())
A = []
for i in range (0, M):
	A.append(list(map(int, input().split())))

P = list(map(int, input().split()))

L = list(it.product([0,1], repeat = N))

combinations = 0
count = 0
summary = 0

for i in range (0, len(L)):
	count = 0
	for j in range (0,M):
		summary = 0
		for k in range (0, len(A[j])):
			summary+=L[i][A[j][k]-1]
		if summary%2 == P[j]:
			count = 1    
	if count == 0:
		combinations+=1

print(combinations)