N, M = map(int, input().split())
S = []
for _ in range(M):
    S.append(list(map(int, input().split()))[1:])
p = map(int, input().split())
ans = 0
for bit in range(1 << N):
    for m in range(M):
        if p[m] != ([str(bit).zfill(N)[s-1] for s in S[m]].count('1') % 2):
            break
    else:
        ans += 1
print(ans)
