n,m = map(int, input().split())
sws=[]
for _ in range(m):
  sws.append(list(map(int, input().split()))[1:])
p = list(map(int, input().split()))

ans=0
for i in range(2**n):
  for j in range(m):
    t = 0
    for sw in sws[j]:
      if ((i >> (sw-1)) & 1):
        t += 1
    if t%2 != p[j]:
      break
  else:
    ans+=1
print(ans)