def main():
  import itertools
  n,m=map(int,input().split())
  li=[list(map(int,input().split())) for _ in range(m)]
  p=list(map(int,input().split()))
  li=[set(x[1:]) for x in li]
  
  ans=0
  g=range(1,n+1)
  
  for i in g:
    for s in itertools.combinations(g,i):
      s=set(s)
      for i,t in enumerate(li):
        u=s&t
        if len(u)%2==p[i]:
          continue
        else:
          break
      else:
        ans+=1
   
  print(ans)
  
  
if __name__=="__main__":
  main()