N, M = map(int, input().split())
switch = []
for _ in range(M):
  tmp = list(map(int, input().split()))
  switch.append(tmp[1:])
p = list(map(int, input().split()))

from itertools import product
candidate = list(product([0,1], repeat=N))

ans = 0
for cand in candidate:
  flag = True
  for idx, snum in enumerate(switch):
    tmp = 0
    for s in snum:
      tmp += cand[s-1]
    if p[idx] != tmp%2:
      flag = False
      break
  if flag:
    ans += 1
print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M switch = [] switch [] for _ in range(M):
  tmp = list(map(int, input().split()))
  switch.append(tmp[1:]) _ range(M) range M tmp = list(map(int, input().split())) tmp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split switch.append(tmp[1:]) switch.append switch append tmp[1:] tmp 1: 1 p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split from itertools import product candidate = list(product([0,1], repeat=N)) candidate list(product([0,1], repeat=N)) list product([0,1], repeat=N) product [0,1] 0 1 repeat=N repeat N ans = 0 ans 0 for cand in candidate:
  flag = True
  for idx, snum in enumerate(switch):
    tmp = 0
    for s in snum:
      tmp += cand[s-1]
    if p[idx] != tmp%2:
      flag = False
      break
  if flag:
    ans += 1 cand candidate flag = True flag True for idx, snum in enumerate(switch):
    tmp = 0
    for s in snum:
      tmp += cand[s-1]
    if p[idx] != tmp%2:
      flag = False
      break
   idx snum enumerate(switch) enumerate switch tmp = 0 tmp 0 for s in snum:
      tmp += cand[s-1]
     s snum tmp += cand[s-1] tmp cand[s-1] cand s-1 s 1 if p[idx] != tmp%2:
      flag = False
      break
   p[idx] != tmp%2 p[idx] p idx tmp%2 tmp 2 flag = False flag False break if flag:
    ans += 1 flag ans += 1 ans 1 print(ans) print ans p = list(map(int, input().split())) list(map(int, input().split())) p tmp = 0 0 tmp tmp += cand[s-1] cand[s-1] tmp ans = 0 0 ans N, M = map(int, input().split()) map(int, input().split()) N flag = True True flag ans += 1 1 ans flag = False False flag M = map(int, input().split()) map(int, input().split()) M switch = [] [] switch tmp = list(map(int, input().split())) list(map(int, input().split())) tmp candidate = list(product([0,1], repeat=N)) list(product([0,1], repeat=N)) candidate
N, M = map(int, input().split())
switch = []
for _ in range(M):
  tmp = list(map(int, input().split()))
  switch.append(tmp[1:])
p = list(map(int, input().split()))

from itertools import product
candidate = list(product([0,1], repeat=N))

ans = 0
for cand in candidate:
  flag = True
  for idx, snum in enumerate(switch):
    tmp = 0
    for s in snum:
      tmp += cand[s-1]
    if p[idx] != tmp%2:
      flag = False
      break
  if flag:
    ans += 1
print(ans)