N, M = map(int, input().split())
S = []
for i in range(M):
  S.append(list(map(int, input().split())))
P = list(map(int, input().split()))
ans = 0
for n in range(2 ** N):
  t = [(n >> i) & 1 for i in range(N)]
  f = 0
  for j in range(M):
    c = 0
    for k in S[j][1:]:
      c ^= t[k-1]
    if c != P[j]:
      f = 1
      break
  if f == 0:
    ans += 1
print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M S = [] S [] for i in range(M):
  S.append(list(map(int, input().split()))) i range(M) range M S.append(list(map(int, input().split()))) S.append S append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 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 n in range(2 ** N):
  t = [(n >> i) & 1 for i in range(N)]
  f = 0
  for j in range(M):
    c = 0
    for k in S[j][1:]:
      c ^= t[k-1]
    if c != P[j]:
      f = 1
      break
  if f == 0:
    ans += 1 n range(2 ** N) range 2 ** N 2 N (n >> i) & 1 for i in range(N) for i in range(N) i range(N) range N for i in range(N) (n >> i) & 1 n >> i n i 1 t = [(n >> i) & 1 for i in range(N)] t [(n >> i) & 1 for i in range(N)] f = 0 f 0 for j in range(M):
    c = 0
    for k in S[j][1:]:
      c ^= t[k-1]
    if c != P[j]:
      f = 1
      break
   j range(M) range M c = 0 c 0 for k in S[j][1:]:
      c ^= t[k-1]
     k S[j][1:] [j] S j 1: 1 c ^= t[k-1] c t[k-1] t k-1 k 1 if c != P[j]:
      f = 1
      break
   c != P[j] c P[j] P j f = 1 f 1 break if f == 0:
    ans += 1 f == 0 f 0 ans += 1 ans 1 print(ans) print ans f = 1 1 f N, M = map(int, input().split()) map(int, input().split()) N f = 0 0 f ans = 0 0 ans t = [(n >> i) & 1 for i in range(N)] [(n >> i) & 1 for i in range(N)] t M = map(int, input().split()) map(int, input().split()) M c ^= t[k-1] t[k-1] c S = [] [] S P = list(map(int, input().split())) list(map(int, input().split())) P c = 0 0 c ans += 1 1 ans
N, M = map(int, input().split())
S = []
for i in range(M):
  S.append(list(map(int, input().split())))
P = list(map(int, input().split()))
ans = 0
for n in range(2 ** N):
  t = [(n >> i) & 1 for i in range(N)]
  f = 0
  for j in range(M):
    c = 0
    for k in S[j][1:]:
      c ^= t[k-1]
    if c != P[j]:
      f = 1
      break
  if f == 0:
    ans += 1
print(ans)