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