n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
ans=0
for bit in range(2**n):
  ok=True
  for j in range(m):
    c=0
    k=s[j][0]
    for l in range(1,k+1):
      if (bit &(1<<(s[j][l]-1))):c+=1
    if c%2!=p[j]:ok=False
  if ok:ans+=1
print(ans)


