n,m=map(int,input().split())
s=[]
for _ in range(m):
  k,*b=map(int,input().split())
  s.append(b)
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  tr=bin(i)[2:].zfill(n)
  light=0
  for j in range(m):
    sw=0
    for l in s[j]:
      if tr[l-1]=='1':
        sw+=1
    if sw%2==p[j]:
      light+=1
  if light==m:
    ans+=1
print(ans)