n,m=map(int,input().split())
ans=0
e=[set(list(map(int,input().split()))[1:]) for i in range(m)]
f=list(map(int,input().split()))
for i in range(2**n):
  l={a for a,b in zip(range(1,n+1),bin(i)[2:].zfill(n)) if b=="1"}
  for j in range(1,m+1):
    if len(e[j-1]&l)%2!=f[j-1]:break
  else:ans+=1
print(ans)