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

ans = 0
for i in range(1 << N):
  tmp = 1
  cnt = 0
  for j, b in enumerate(KS):
    for bb in b:
      if (i >> bb) & 1:
        cnt += 1
    if cnt%2 != P[j]:
      tmp = 0
      break
  if tmp:
    ans += 1
print(ans)