f=lambda:map(int,input().split())
n,m=f()
S=[[0]*n for _ in range(m)]
for i in range(m):
  _,*s=f()
  for j in s: S[i][j-1]=1
p=[*f()]
a=0
for i in range(2**n):
  if all(sum(S[k][j] for j in range(n) if i>>j&1)%2==p[k] for k in range(m)): a+=1
print(a)