def ma():
  n,m=map(int,input().split())
  ans=0
  e=[set(list(map(int,input().split()))[1:]) for i in range(m)]
  f=list(map(int,input().split()))
  for i in range(2**n):
    l={a for a,b in zip(range(1,n+1),bin(i)[2:].zfill(n)) if b=="1"}
    if sum([int(len(e[j-1]&l)%2 !=f[j-1]) for j in range(1,m+1)])==0:ans+=1
  print(ans)

if __name__=="__main__":
  ma()