n,m=map(int,input().split())
k=[]
ans=0
for i in range(m):
      a=list(map(int,input().split()))
      k.append(a)
p=list(map(int,input().split()))
for i in range(2**n):
      L=[0]*n
      for j in range(n):
            if ((i>>j)&1):
                  L[j]=1
      flag=True
      for j in range(n):
            s=0
            for e in range(k[j][0]):
                  s+=L[k[j][e+1]-1]
            if s%2!=p[j]:
                  flag=False
      if flag:
            ans+=1
print(ans)
                 