import itertools
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
ks = []
for i in range(M):
    ks.append(inpl())
p = inpl()

ans = 0
for s in itertools.product(range(2),repeat=N):
    for i in range(M):
        if (sum([ s[n-1] for n in ks[i][1:]]) - p[i]) % 2:
            break
    else:
        ans += 1

print(ans)