#c
n,m = map(int,input().split())
k = [0]*m
s=[]
for i in range(m):
    k[i],*ss = map(int,input().split())
    s.append( ss )
p = list(map(int,input().split()))


ans=0
for i in range(2**n):
    bi = bin(i)[2:].zfill(n)
    if all( sum(int(bi[sss-1]) for sss in ss )%2 == p[j] for j,ss in enumerate(s) ):
        ans+=1
print(ans)