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