n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
p=list(map(int,input().split()))
a=0
for bit in range(1<<n):
 for j in range(m):
  c=0
  for k in s[j][1:]:
   if bit&(1<<(k-1)):c+=1
  if c%2!=p[j]:break
 else:a+=1
print(a)