n,m=map(int,input().split())
s=[list(map(int,input().split())) for x in range(m)]
p=list(map(int,input().split()))
ans=0
for b in range(1<<n):
  flg=True
  for i in range(m):
    cnt=0
    for j in range(s[i][0]):
      if (b >> s[i][j+1]-1)&1:
        cnt+=1
    if cnt %2==p[i]:
      flg=False
  if flg:
    ans+=1
print(ans)