from operator import itemgetter
n, m = map(int, input().split())
s = []
for i in range(m):
  s.append([i - 1 for i in list(map(int, input().split()))[1:]])
p = list(map(int, input().split()))
r = 0
for i in range(2 ** n):
  lst = list(map(int, bin(i)[2:].zfill(n)))
  f = True
  for j in range(m):
    if len(s[j]) > 2:
      getter = itemgetter(*s[j])
      if sum(getter(lst)) % 2 != p[j]:
        f = False
        break
    else:
      if lst[s[j][0]] % 2 != p[j]:
        f = False
        break
  if f:
    r += 1
print(r)