import itertools

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

ans = 0
for t in itertools.product([0, 1], repeat=N):
    for m in range(M):
        if sum(t[x - 1] for x in KS[m][1:]) % 2 != P[m]:
            break
    else:
        ans += 1

print(ans)