from itertools import product


n,m = map(int, input().split())

switch = []

for i in range(m):
  k, *s = map(int, input().split())
  s = list(s)
  switch.append(s)

p = list(map(int, input().split()))
ans = 0

for i in product(range(2), repeat=n):
  flag = True
  for s in range(m):
    cnt = 0
    for t in switch[s]:
      if i[t-1] == 1:
        cnt += 1
    if cnt % 2 != p[s]:
      flag = False
      break
  if flag == True:
    ans += 1

print(ans) from itertools import product n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m switch = [] switch [] for i in range(m):
  k, *s = map(int, input().split())
  s = list(s)
  switch.append(s) i range(m) range m k, *s = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *s s s = list(s) s list(s) list s switch.append(s) switch.append switch append s p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in product(range(2), repeat=n):
  flag = True
  for s in range(m):
    cnt = 0
    for t in switch[s]:
      if i[t-1] == 1:
        cnt += 1
    if cnt % 2 != p[s]:
      flag = False
      break
  if flag == True:
    ans += 1 i product(range(2), repeat=n) product range(2) range 2 repeat=n repeat n flag = True flag True for s in range(m):
    cnt = 0
    for t in switch[s]:
      if i[t-1] == 1:
        cnt += 1
    if cnt % 2 != p[s]:
      flag = False
      break
   s range(m) range m cnt = 0 cnt 0 for t in switch[s]:
      if i[t-1] == 1:
        cnt += 1
     t switch[s] switch s if i[t-1] == 1:
        cnt += 1
     i[t-1] == 1 i[t-1] i t-1 t 1 1 cnt += 1 cnt 1 if cnt % 2 != p[s]:
      flag = False
      break
   cnt % 2 != p[s] cnt % 2 cnt 2 p[s] p s flag = False flag False break if flag == True:
    ans += 1 flag == True flag True ans += 1 ans 1 print(ans) print ans ans += 1 1 ans k, *s = map(int, input().split()) map(int, input().split()) k p = list(map(int, input().split())) list(map(int, input().split())) p n,m = map(int, input().split()) map(int, input().split()) n switch = [] [] switch ans = 0 0 ans s = list(s) list(s) s cnt += 1 1 cnt m = map(int, input().split()) map(int, input().split()) m cnt = 0 0 cnt flag = True True flag flag = False False flag
from itertools import product


n,m = map(int, input().split())

switch = []

for i in range(m):
  k, *s = map(int, input().split())
  s = list(s)
  switch.append(s)

p = list(map(int, input().split()))
ans = 0

for i in product(range(2), repeat=n):
  flag = True
  for s in range(m):
    cnt = 0
    for t in switch[s]:
      if i[t-1] == 1:
        cnt += 1
    if cnt % 2 != p[s]:
      flag = False
      break
  if flag == True:
    ans += 1

print(ans)