#abc128c
n,m=map(int,raw_input().split())
s=[map(int,raw_input().split()) for i in range(m)]
p=map(int,raw_input().split())
res=0
for i in range(2**n):
 res+=1
 for j in range(len(s)):
  on=0
  for k in range(s[j][0]):
   on+=((i>>(s[j][k+1]-1))%2)
  if on%2!=p[j]:
   res-=1
   break
print res
