n,m=map(int,input().split())

info=[list(map(int,input().split())) for i in range(m)]

p=list(map(int,input().split()))

ans=0
for i in range(2**n):
  tmp=0
  f=1
  for mm in range(m):
    tmp=0
    for j in info[mm][1:]:
      tmp+=int(str(format(i,'b').zfill(n))[int(j)-1])
    if tmp%2!=p[mm]:
      f=0
  if f==1:
    ans+=1
print(ans)
