o=lambda:map(int,input().split())
n,m=o()
l=[list(o())[1:]for _ in range(m)]
l=[''.join('1'if e+1 in c else'0'for e in range(m))[::-1]for c in l]
p=list(o())
t="%0{}d".format(n)
r=0
for i in range(2**n):
  q=t%int(bin(i).replace("0b",""))
  f=[]
  for c in l:
    v=int(q,2)&int(c,2)
    f+=[sum(map(int,bin(v).replace("0b","")))%2]
  r+= f == p
print(r)