N, M = map(int, raw_input().split())
s = [[int(t)-1 for t in raw_input().split()[1:]] for _ in range(M)]
p = map(int, raw_input().split())

ans = 0
for b in range(1<<N):
  ok = True
  for i in range(M):
    c = 0
    for t in s[i]:
      if b>>t&1:
        c += 1
    if c%2!=p[i]:
      ok = False
  if ok:
    ans += 1
print ans
