N, M = map(int,input().split())
S = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

ans = 0
for i in range(1 << N):
  f = True
  for j in range(M):
    tmp = 0
    for k in range(1,S[j][0]):
      if ((i >> S[j][k]) & 1):
        tmp += 1
    tmp %= 2
    if tmp != P[j]:
      f = False
  if f:
    ans += 1
print(ans)