import itertools
N, M = map(int, input().split())
ks = []
k_max = 0
for i in range(M):
	ks_in = list(map(int, input().split()))
	k_max = max(k_max, max(ks_in[1:]))
	ks.append(ks_in)
p = list(map(int, input().split()))

A = [0, 1]
lt = list(itertools.product(A, repeat=k_max))
count = 0
for elem in lt:
	for i in range(M):
		sum = 0
		for j in range(len(ks[i])-1):
			sum += elem[ks[i][j+1]-1]
		if sum % 2 != p[i]:
			break
	else:
		count += 1
print(count)