n,m=map(int,input().split())
k=[list(map(int,input().split()))[1:]for _ in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  f=True
  for j in range(m):
    x=k[j]
    c=0
    for h in x:
      if s[h-1]=="0":c+=1
    if c%2!=p[j]:f=False
  if f:ans+=1
print(ans)