n,m=map(int,input().split())
ks=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  q=[0]*n
  for j in range(n):
    if i>>j&1:
      q[j]=1
  for j in range(m):
    cnt=0
    for k in ks[j][1:]:
      if q[k-1]==1:
        cnt+=1
    if cnt%2!=p[j]%2:
      break
  else:
    ans+=1
print(ans)