n,m=map(int,input().split())
swiches=[]
for i in range(m):
	s=0
	for j in list(map(int,input().split()))[1:]:
		s+=2**(j-1)
	swiches.append(s)
pli=list(map(int,input().split()))
cnt=0
for i in range(2**n):
	flag=True
	for p,s in zip(pli,swiches):
		if p!=bin(i&s).count("1")%2:
			flag=False
			break
	if flag:
		cnt+=1
print(cnt)