n,m=map(int,input().split())
L=[]
for i in range(m):
    l=[]
    l=list(map(int,input().split()))
    s=0
    for j in range(l[0]):
        s+=2**(l[j+1]-1)
        L.append(s)
P=list(map(int,input().split()))
r=0
for i in range(1<<n):
	p=0
	for j in range(m):
		if bin(i&L[j]).count('1')%2==P[j]:
			p+=1
	if p==m:
		r+=1
print(r)