n, m = map(int, input().split())
state = []
for _ in range(m):
  lst = list(map(int, input().split()))
  state.append(lst[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
  total = 0
  for j in range(m):
    cnt = 0
    for s in state[j]:
      s -= 1
      if (i >> s) & 1:
        cnt += 1
    cnt %= 2
    if cnt == p[j]:
      total += 1
  if total == m:
    ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m state = [] state [] for _ in range(m):
  lst = list(map(int, input().split()))
  state.append(lst[1:]) _ range(m) range m lst = list(map(int, input().split())) lst list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split state.append(lst[1:]) state.append state append lst[1:] lst 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 ans = 0 ans 0 for i in range(2**n):
  total = 0
  for j in range(m):
    cnt = 0
    for s in state[j]:
      s -= 1
      if (i >> s) & 1:
        cnt += 1
    cnt %= 2
    if cnt == p[j]:
      total += 1
  if total == m:
    ans += 1 i range(2**n) range 2**n 2 n total = 0 total 0 for j in range(m):
    cnt = 0
    for s in state[j]:
      s -= 1
      if (i >> s) & 1:
        cnt += 1
    cnt %= 2
    if cnt == p[j]:
      total += 1
   j range(m) range m cnt = 0 cnt 0 for s in state[j]:
      s -= 1
      if (i >> s) & 1:
        cnt += 1
     s state[j] state j s -= 1 s 1 if (i >> s) & 1:
        cnt += 1
     (i >> s) & 1 i >> s i s 1 cnt += 1 cnt 1 cnt %= 2 cnt 2 if cnt == p[j]:
      total += 1
   cnt == p[j] cnt p[j] p j total += 1 total 1 if total == m:
    ans += 1 total == m total m ans += 1 ans 1 print(ans) print ans cnt += 1 1 cnt state = [] [] state lst = list(map(int, input().split())) list(map(int, input().split())) lst total += 1 1 total cnt %= 2 2 cnt s -= 1 1 s n, m = map(int, input().split()) map(int, input().split()) n cnt = 0 0 cnt m = map(int, input().split()) map(int, input().split()) m ans = 0 0 ans p = list(map(int, input().split())) list(map(int, input().split())) p total = 0 0 total ans += 1 1 ans
n, m = map(int, input().split())
state = []
for _ in range(m):
  lst = list(map(int, input().split()))
  state.append(lst[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
  total = 0
  for j in range(m):
    cnt = 0
    for s in state[j]:
      s -= 1
      if (i >> s) & 1:
        cnt += 1
    cnt %= 2
    if cnt == p[j]:
      total += 1
  if total == m:
    ans += 1
print(ans)