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