n,m=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(m)]
k2=[]
for v in k:
  a=[2**(v[i]-1) for i in range(1,v[0]+1)]
  k2.append(sum(a))
  
p=list(map(int,input().split()))

sm=0
for i in range(2**n):
  c=1
  for j in range(m):
    b=bin(k2[j] &i)
    
    d=b.count("1")
    if d%2!=p[j]:
      c=0
  if c==1:
    sm+=1

print(sm)