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

result = 0
for i in range(2 ** N):
    if all(sum(["{:0{N}b}".format(i, N=N)[t - 1] == '1' for t in s]) % 2 == P[j] for j, s in enumerate(S)):
        result += 1

print(result)
