N, M = map(int, input().split())
K = [set(list(map(int, input().split()))[1:]) for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    S = set([1+j for j in range(N) if 2**j & i])
    for j, k in enumerate(K):
        if len(S.intersection(k))%2 != P[j]:
            break
    else:
        ans += 1
print(ans)