N, M = map(int, input().split(' '))

On = [True for i in range(N)]
K = [0 for j in range(M)]
S = []

for j in range(M):
  inp = list(map(int, input().split(' ')))
  K[j] = inp[0]
  S.append(inp[1:])
  
P = list(map(int, input().split(' ')))


def check_condition(On, K, S, P):
  for j in range(len(K)):
    on_sum = 0
    for k in range(K[j]):
      if On[S[j][k]-1]: on_sum += 1
    if on_sum%2 != P[j]:
      return False
  return True

def enum_patterns(On, index, K, S, P):
  off = On.copy()
  off[index] = False
  if index == len(On)-1:
    count = check_condition(On, K, S, P) + check_condition(off, K, S, P)
  else:
    count = enum_patterns(On, index+1, K, S, P) + enum_patterns(off, index+1, K, S, P)
  return count


print(enum_patterns(On, 0, K, S, P)) N, M = map(int, input().split(' ')) N map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' M True for i in range(N) for i in range(N) i range(N) range N for i in range(N) True On = [True for i in range(N)] On [True for i in range(N)] 0 for j in range(M) for j in range(M) j range(M) range M for j in range(M) 0 K = [0 for j in range(M)] K [0 for j in range(M)] S = [] S [] for j in range(M):
  inp = list(map(int, input().split(' ')))
  K[j] = inp[0]
  S.append(inp[1:])
   j range(M) range M inp = list(map(int, input().split(' '))) inp list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' K[j] = inp[0] K[j] K j inp[0] inp 0 S.append(inp[1:]) S.append S append inp[1:] inp 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 ' ' def check_condition(On, K, S, P):
  for j in range(len(K)):
    on_sum = 0
    for k in range(K[j]):
      if On[S[j][k]-1]: on_sum += 1
    if on_sum%2 != P[j]:
      return False
  return True check_condition for j in range(len(K)):
    on_sum = 0
    for k in range(K[j]):
      if On[S[j][k]-1]: on_sum += 1
    if on_sum%2 != P[j]:
      return False
   j range(len(K)) range len(K) len K on_sum = 0 on_sum 0 for k in range(K[j]):
      if On[S[j][k]-1]: on_sum += 1
     k range(K[j]) range K[j] K j if On[S[j][k]-1]: on_sum += 1
     On[S[j][k]-1] On S[j][k]-1 S[j][k] [j] S j k 1 if on_sum%2 != P[j]:
      return False
   on_sum%2 != P[j] on_sum%2 on_sum 2 P[j] P j return False False return True True On On K K S S P P def enum_patterns(On, index, K, S, P):
  off = On.copy()
  off[index] = False
  if index == len(On)-1:
    count = check_condition(On, K, S, P) + check_condition(off, K, S, P)
  else:
    count = enum_patterns(On, index+1, K, S, P) + enum_patterns(off, index+1, K, S, P)
  return count enum_patterns off = On.copy() off On.copy() On.copy On copy off[index] = False off[index] off index False if index == len(On)-1:
    count = check_condition(On, K, S, P) + check_condition(off, K, S, P)
  else:
    count = enum_patterns(On, index+1, K, S, P) + enum_patterns(off, index+1, K, S, P)
   index == len(On)-1 index len(On)-1 len(On) len On 1 count = check_condition(On, K, S, P) + check_condition(off, K, S, P) count check_condition(On, K, S, P) + check_condition(off, K, S, P) check_condition(On, K, S, P) check_condition On K S P check_condition(off, K, S, P) check_condition off K S P count = enum_patterns(On, index+1, K, S, P) + enum_patterns(off, index+1, K, S, P) count enum_patterns(On, index+1, K, S, P) + enum_patterns(off, index+1, K, S, P) enum_patterns(On, index+1, K, S, P) enum_patterns On index+1 index 1 K S P enum_patterns(off, index+1, K, S, P) enum_patterns off index+1 index 1 K S P return count count On On index index K K S S P P print(enum_patterns(On, 0, K, S, P)) print enum_patterns(On, 0, K, S, P) enum_patterns On 0 K S P P = list(map(int, input().split(' '))) list(map(int, input().split(' '))) P def check_condition(On, K, S, P):
  for j in range(len(K)):
    on_sum = 0
    for k in range(K[j]):
      if On[S[j][k]-1]: on_sum += 1
    if on_sum%2 != P[j]:
      return False
  return True def check_condition(On, K, S, P):
  for j in range(len(K)):
    on_sum = 0
    for k in range(K[j]):
      if On[S[j][k]-1]: on_sum += 1
    if on_sum%2 != P[j]:
      return False
  return True check_condition inp = list(map(int, input().split(' '))) list(map(int, input().split(' '))) inp K = [0 for j in range(M)] [0 for j in range(M)] K N, M = map(int, input().split(' ')) map(int, input().split(' ')) N M = map(int, input().split(' ')) map(int, input().split(' ')) M S = [] [] S def enum_patterns(On, index, K, S, P):
  off = On.copy()
  off[index] = False
  if index == len(On)-1:
    count = check_condition(On, K, S, P) + check_condition(off, K, S, P)
  else:
    count = enum_patterns(On, index+1, K, S, P) + enum_patterns(off, index+1, K, S, P)
  return count def enum_patterns(On, index, K, S, P):
  off = On.copy()
  off[index] = False
  if index == len(On)-1:
    count = check_condition(On, K, S, P) + check_condition(off, K, S, P)
  else:
    count = enum_patterns(On, index+1, K, S, P) + enum_patterns(off, index+1, K, S, P)
  return count enum_patterns On = [True for i in range(N)] [True for i in range(N)] On
N, M = map(int, input().split(' '))

On = [True for i in range(N)]
K = [0 for j in range(M)]
S = []

for j in range(M):
  inp = list(map(int, input().split(' ')))
  K[j] = inp[0]
  S.append(inp[1:])
  
P = list(map(int, input().split(' ')))


def check_condition(On, K, S, P):
  for j in range(len(K)):
    on_sum = 0
    for k in range(K[j]):
      if On[S[j][k]-1]: on_sum += 1
    if on_sum%2 != P[j]:
      return False
  return True

def enum_patterns(On, index, K, S, P):
  off = On.copy()
  off[index] = False
  if index == len(On)-1:
    count = check_condition(On, K, S, P) + check_condition(off, K, S, P)
  else:
    count = enum_patterns(On, index+1, K, S, P) + enum_patterns(off, index+1, K, S, P)
  return count


print(enum_patterns(On, 0, K, S, P))