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

Ks = []
for _ in range(M):
  Ks.append(set(list(map(int, input().split()))[1:]))
  
Ps = list(map(int, input().split()))

rlt = 0
pw = 2**N

for b in range(pw):
  lst = [0]*(M)
  tmp = 0
  for i in range(N):
    if b&(1<<i):
      for j in range(M):
        if i+1 in Ks[j]:
          lst[j] += 1
  for j in range(M):
    if lst[j] % 2 == Ps[j]:
      tmp += 1
  if tmp == M:
    rlt += 1
  
print(rlt) N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M Ks = [] Ks [] for _ in range(M):
  Ks.append(set(list(map(int, input().split()))[1:]))
   _ range(M) range M Ks.append(set(list(map(int, input().split()))[1:])) Ks.append Ks append set(list(map(int, input().split()))[1:]) set list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 1: 1 Ps = list(map(int, input().split())) Ps list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split rlt = 0 rlt 0 pw = 2**N pw 2**N 2 N for b in range(pw):
  lst = [0]*(M)
  tmp = 0
  for i in range(N):
    if b&(1<<i):
      for j in range(M):
        if i+1 in Ks[j]:
          lst[j] += 1
  for j in range(M):
    if lst[j] % 2 == Ps[j]:
      tmp += 1
  if tmp == M:
    rlt += 1
   b range(pw) range pw lst = [0]*(M) lst [0]*(M) [0] 0 M tmp = 0 tmp 0 for i in range(N):
    if b&(1<<i):
      for j in range(M):
        if i+1 in Ks[j]:
          lst[j] += 1
   i range(N) range N if b&(1<<i):
      for j in range(M):
        if i+1 in Ks[j]:
          lst[j] += 1
   b&(1<<i) b 1<<i 1 i for j in range(M):
        if i+1 in Ks[j]:
          lst[j] += 1
   j range(M) range M if i+1 in Ks[j]:
          lst[j] += 1
   i+1 in Ks[j] i+1 i 1 Ks[j] Ks j lst[j] += 1 lst[j] lst j 1 for j in range(M):
    if lst[j] % 2 == Ps[j]:
      tmp += 1
   j range(M) range M if lst[j] % 2 == Ps[j]:
      tmp += 1
   lst[j] % 2 == Ps[j] lst[j] % 2 lst[j] lst j 2 Ps[j] Ps j tmp += 1 tmp 1 if tmp == M:
    rlt += 1
   tmp == M tmp M rlt += 1 rlt 1 print(rlt) print rlt lst = [0]*(M) [0]*(M) lst tmp = 0 0 tmp pw = 2**N 2**N pw tmp += 1 1 tmp rlt += 1 1 rlt rlt = 0 0 rlt Ks = [] [] Ks M = map(int, input().split()) map(int, input().split()) M Ps = list(map(int, input().split())) list(map(int, input().split())) Ps N,M = map(int, input().split()) map(int, input().split()) N
N,M = map(int, input().split())

Ks = []
for _ in range(M):
  Ks.append(set(list(map(int, input().split()))[1:]))
  
Ps = list(map(int, input().split()))

rlt = 0
pw = 2**N

for b in range(pw):
  lst = [0]*(M)
  tmp = 0
  for i in range(N):
    if b&(1<<i):
      for j in range(M):
        if i+1 in Ks[j]:
          lst[j] += 1
  for j in range(M):
    if lst[j] % 2 == Ps[j]:
      tmp += 1
  if tmp == M:
    rlt += 1
  
print(rlt)