N, M = map(int, input().split())
D = [[] for i in range(N)]
for i in range(M):
    a = [int(j) for j in input().split()]
    for v in a[1:]:
        D[v - 1].append(i)

P = [int(i) for i in input().split()]
print(D)
ans = 0
for i in range(1 << N):
    S = [0] * M #各電球が何回スイッチ入ってるか
    for k in range(N):
        if ((i >> k) & 1) == 1:
            for d in D[k]:
                S[d] += 1

    if all([(s % 2) == p for  s,p in zip(S, P)]):
        ans += 1

print(ans)