N, M = map(int, input().split())
L = []
for _ in range(M):
  k, *S = map(int, input().split())
  L.append(S)
P = list(map(int, input().split()))
c = 0
for i in range(2**N):
  A = []
  for j in range(N):
    if (i>>j)&1:
      A.append(j+1)
  A = set(A)
  for i in range(M):
    if len(A&set(L[i]))%2!=P[i]:
      break
  else:
    c += 1
print(c) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [] L [] for _ in range(M):
  k, *S = map(int, input().split())
  L.append(S) _ range(M) range M k, *S = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *S S L.append(S) L.append L append S P = list(map(int, input().split())) P list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c = 0 c 0 for i in range(2**N):
  A = []
  for j in range(N):
    if (i>>j)&1:
      A.append(j+1)
  A = set(A)
  for i in range(M):
    if len(A&set(L[i]))%2!=P[i]:
      break
  else:
    c += 1 i range(2**N) range 2**N 2 N A = [] A [] for j in range(N):
    if (i>>j)&1:
      A.append(j+1)
   j range(N) range N if (i>>j)&1:
      A.append(j+1)
   (i>>j)&1 i>>j i j 1 A.append(j+1) A.append A append j+1 j 1 A = set(A) A set(A) set A for i in range(M):
    if len(A&set(L[i]))%2!=P[i]:
      break
  else:
    c += 1 i range(M) range M if len(A&set(L[i]))%2!=P[i]:
      break
   len(A&set(L[i]))%2!=P[i] len(A&set(L[i]))%2 len(A&set(L[i])) len A&set(L[i]) A set(L[i]) set L[i] L i 2 P[i] P i break c += 1 c 1 print(c) print c A = [] [] A N, M = map(int, input().split()) map(int, input().split()) N c = 0 0 c c += 1 1 c A = set(A) set(A) A L = [] [] L P = list(map(int, input().split())) list(map(int, input().split())) P M = map(int, input().split()) map(int, input().split()) M k, *S = map(int, input().split()) map(int, input().split()) k
N, M = map(int, input().split())
L = []
for _ in range(M):
  k, *S = map(int, input().split())
  L.append(S)
P = list(map(int, input().split()))
c = 0
for i in range(2**N):
  A = []
  for j in range(N):
    if (i>>j)&1:
      A.append(j+1)
  A = set(A)
  for i in range(M):
    if len(A&set(L[i]))%2!=P[i]:
      break
  else:
    c += 1
print(c)