n,m=map(int,input().split())
lis=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
s=0
for i in range(2**n):
  ok=True
  for k in range(m):
    cnt=0
    for j in range(n):
      if (i>>j)&1:
        if j+1 in lis[k][1:]:
          cnt+=1
    if cnt%2!=p[k]:
      ok=False
  if ok:
    s+=1
print(s)