n, m = map(int, input().split())
s = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
ans = 0
for num in range(1<<n):
	all = True
	for M in range(m):
		swt = 0
		for k in s[M][1:]:
			if num&(1<<(k-1)):
				swt += 1
		if swt % 2 != p[M]:
			all = False
			break
	if all:
		ans += 1
print(ans)		