n,m=map(int,input().split())

l=[[int(x) for x in input().split()] for _ in range(m)]
p=[int(x) for x in input().split()]

t=0
for i in range(2**n):
  f = True
  for j in range(m):
     c=0
     for k in range(1,l[j][0]+1):
       if (i>>(l[j][k]-1)) & 1:
         c+=1
     if (c&1)!=p[j]:
        f = False
        break
  if f==True:
    t+=1

print(t)
