N, M = map(int, input().split())

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

p = list(map(int, input().split()))


cnt = 0
for L in range(pow(2, N)):

    for pi, s in zip(p, Ss):
        x = pi
        for si in s:
            x ^= ((L & (1 << (si - 1))) != 0) * 1
        if x != 0:
            break
    else:
        cnt += 1

print(cnt)
