ans = 0
for bit in range(1<<N):
    count = [0]*M
    for i in range(N):
        if (bit >> i) & 1:
            for a in range(M):
                if i in ks[a][1:]:
                    count[a] +=1
    a = 0
    for i in range(M):
        if count[i] % 2 == p[i]:
            a += 1
            if a == M:
                ans += 1

print(ans)
