f=lambda:map(int,input().split())
n,m=f()
ll=[[0]*n for _ in range(m)]
for l in ll:
  k,*s=f()
  for i in s: l[i-1]=1
p=list(f())
import itertools as it
print(sum(all(sum(a*b for a,b in zip(l,t))%2==p[i] for i,l in enumerate(ll)) for t in it.product([0,1],repeat=n)))