N, M = map(int, input().split())
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

pattern_count = 0
for n in range(2 ** N):
	switch_count = 0
	for i, ks in enumerate(KS):
		for s in ks[1:]:
			if n >> (s - 1) & 1:
				switch_count += 1
		else:
			if switch_count % 2 != P[i]:
				break
	else:
		pattern_count += 1
print(pattern_count)
