ks=[]
n,m=map(int,input().split())
for i in range(m):
	ks.append(list(map(int,input().split())))
p=list(map(int,input().split()))
ans_ans=0
for i in range(2**n):
	num="0"*10+bin(i)
	ans=0
	for j in range(m):
		cnt=0
		for k in range(n):
			if num[-k-1]=="1" and k+1 in ks[j][1:]:
				cnt+=1
		if cnt%2==p[j]:
			ans+=1
	if ans==m:
		ans_ans+=1
print(ans_ans)


		
