n,m=map(int,input().split())
k=[]
cnt=0
flag=True
ans=0
for i in range(m):
  t=list(map(int,input().split()))
  k.append(t)
p=list(map(int,input().split()))

for i in range(2**n):
  flag=True
  cnt=0
  for j in range(m):
    for l in range(len(k[j])-1):
      if (i>>(k[j][l+1]-1))&1:
        cnt+=1
    if cnt%2!=p[j]:
      flag=False
      break
  if flag:
    ans+=1
print(ans)