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

ans = 0
for i in range(1<<N):
  for j, k in enumerate(S):
    if sum(1 for kj in k if (i>>(kj-1) & 1))%2 != P[j]:
      break
    if j == len(S)-1:
      ans += 1

print(ans)