N,M = map(int,input().split())
K = []
S = []
P = []

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

ans = 0

for i in range(2 ** N):
  p = [j for j in P]
  for j in range(M):
    for s in S[j]:
#      print(list(map(int,bin(i + 2 ** (N + 1))[3:])),s)
      if list(map(int,bin(i + 2 ** (N + 1))[3:]))[s - 1] == 1:
        p[j - 1] += 1
#  print(P,p,ans)
  if all([r % 2 == 0 for r in p]):
    ans += 1

print(ans)
      