#25 ABC128C
n,m=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
res=0
for i in range(2**n):
	t=bin(i+2**n)[3:]
	judge=True
	for j in range(m):
		l=0
		for k in ks[j][1:]:
			if t[k-1]=="1":
				l+=1
		if l%2==p[j]:
			continue
		else:
			judge=False
			break
	if judge:
		res+=1
print(res)