import itertools
n, m = map(int, input().split())
kss = []

for mm in range(m):
  ks = list(map(int, input().split()))
  k = ks[0]
  s = ks[1:]
  kss.append(s)
ps = list(map(int, input().split()))


def dfs(kss, ps, ar, n):
  #print(f'dfs called with ar={ar}')
  if len(ar) < n:
    return dfs(kss, ps, ar+[0], n) + dfs(kss, ps, ar+[1], n)
  ok = True
  for m, ks in enumerate(kss):
    sm = 0
    for s in ks:
      sm += ar[s-1]
    if sm % 2 != ps[m-1]:
      ok = False
      break
  #print(f'ar={ar} is {ok}')
  return 1 if ok else 0

count = dfs(kss, ps, [], n)
print(count)

