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

ans = 0
for i in range(2**N):
  tmp = i
  flag = True
  cnt = 0
  for j in range(len(K)):
    for k in range(N):
      if ((i>>k) & 1):
        if k+1 in K[j]:
          cnt += 1
    if cnt % 2 != p[j]:
      flag = False
      break
    else:
      cnt = 0
      i = tmp
  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 K = [] K [] for i in range(M):
  i = list(map(int, input().split()))
  K.append(i[1:]) i range(M) range M i = list(map(int, input().split())) i list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K.append(i[1:]) K.append K append i[1:] i 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):
  tmp = i
  flag = True
  cnt = 0
  for j in range(len(K)):
    for k in range(N):
      if ((i>>k) & 1):
        if k+1 in K[j]:
          cnt += 1
    if cnt % 2 != p[j]:
      flag = False
      break
    else:
      cnt = 0
      i = tmp
  if flag:
    ans += 1 i range(2**N) range 2**N 2 N tmp = i tmp i flag = True flag True cnt = 0 cnt 0 for j in range(len(K)):
    for k in range(N):
      if ((i>>k) & 1):
        if k+1 in K[j]:
          cnt += 1
    if cnt % 2 != p[j]:
      flag = False
      break
    else:
      cnt = 0
      i = tmp
   j range(len(K)) range len(K) len K for k in range(N):
      if ((i>>k) & 1):
        if k+1 in K[j]:
          cnt += 1
     k range(N) range N if ((i>>k) & 1):
        if k+1 in K[j]:
          cnt += 1
     (i>>k) & 1 i>>k i k 1 if k+1 in K[j]:
          cnt += 1
     k+1 in K[j] k+1 k 1 K[j] K j cnt += 1 cnt 1 if cnt % 2 != p[j]:
      flag = False
      break
    else:
      cnt = 0
      i = tmp
   cnt % 2 != p[j] cnt % 2 cnt 2 p[j] p j flag = False flag False break cnt = 0 cnt 0 i = tmp i tmp if flag:
    ans += 1 flag ans += 1 ans 1 print(ans) print ans flag = False False flag K = [] [] K p = list(map(int, input().split())) list(map(int, input().split())) p N, M = map(int, input().split()) map(int, input().split()) N cnt = 0 0 cnt i = list(map(int, input().split())) list(map(int, input().split())) i ans += 1 1 ans M = map(int, input().split()) map(int, input().split()) M i = tmp tmp i tmp = i i tmp cnt += 1 1 cnt cnt = 0 0 cnt flag = True True flag ans = 0 0 ans
N, M = map(int, input().split())
K = []
for i in range(M):
  i = list(map(int, input().split()))
  K.append(i[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(2**N):
  tmp = i
  flag = True
  cnt = 0
  for j in range(len(K)):
    for k in range(N):
      if ((i>>k) & 1):
        if k+1 in K[j]:
          cnt += 1
    if cnt % 2 != p[j]:
      flag = False
      break
    else:
      cnt = 0
      i = tmp
  if flag:
    ans += 1
print(ans)