n,m=map(int,input().split())
l=[list(map(int,input().split()))[1:] for i in range(m)]
p=list(map(int,input().split()))
form = "0" + str(n) + "b"
ans=0
for i in range(2**n):
	ptr = format(i,form)
	flg = True
	for j in range(m):
		s= sum(int(ptr[k-1]) for k in l[j])
		if s%2 != p[j]:
			flg = False
	if flg == True:
		ans+=1
print(ans)