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

K=[list(map(int,input().split())) for _ in range(m)]
p=list(int,input().split())
ans=0
for i in range(1<<n):
  for k in range(m):
    on=0
    for j in range(n):
      if (i&(1<<j)) and j in K[k]:
        on+=1
    if on%2!=p[r]:
      break
  ans+=1
print(ans)