n,m=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

res1=0
for i in range(2**n):
	res2=0
	for j in range(m):
		cnt=0
		for s in range(ks[j][0]):
			if (i>>(ks[j][s+1]-1))&1:
				cnt+=1
		if cnt%2==p[j]:
			res2+=1
	if res2==m:
		res1+=1

print(res1)	