n,m=map(int,input().split())
li=[]
for i in range(m):
  dk,*d=list(map(int,input().split()))
  li.append(d)
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  sw=bin(i)[2:].zfill(n)
  for j in range(m):
    cnt=0
    for k in li[j]:
      if sw[k-1]=='1':
        cnt+=1
    if cnt%2!=p[j]:
      break
  else:ans+=1
print(ans)