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

ans = 0
for i in range(2**n):
  for x,y in zip(s, p):
    flag = False
    for a in x:
      if i & 1 << (a-1):
        flag = not flag
    if int(flag) != y:
      break
  else:
    ans += 1
print(ans)
