from itertools import product

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

cnt = 0
for ss in product([0, 1], repeat=N):
    for i in range(M):
        if sum(ss[sj - 1] for sj in S[i]) % 2 != P[i]:
            break
    else:
        cnt += 1

print(cnt)
