#include #include template void supset_zeta(std::vector &f) { const int n = f.size(); for (int b = 1; b < n; b *= 2) for (int l = 0; l < n; l += 2 * b) for (int p = 0; p < b; ++p) { f[l + p] += f[l + b + p]; } } template void subset_zeta(std::vector &f) { const int n = f.size(); for (int b = 1; b < n; b *= 2) for (int l = 0; l < n; l += 2 * b) for (int p = 0; p < b; ++p) { f[l + b + p] += f[l + p]; } } using Int = int32_t; std::vector calc_f(const size_t n, const size_t, const size_t k, const std::vector& s) { std::vector binom(n + 1, std::vector(n + 1)); for (size_t i = 0; i <= n; ++i) { binom[i][0] = 1; for (size_t j = 1; j <= i; ++j) { binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j]; } } std::vector a(n + 1); for (size_t l = k; l <= n; ++l) { a[l] = 1; for (size_t i = k; i < l; ++i) { a[l] -= a[i] * binom[l][i]; } } std::vector f(1 << n); for (uint u : s) ++f[u]; supset_zeta(f); for (uint t = 0; t < 1u << n; ++t) { if (size_t(__builtin_popcount(t)) < k) { f[t] = 0; } else { f[t] *= a[__builtin_popcount(t)]; } } subset_zeta(f); return f; } std::vector calc_g(const size_t n, const size_t m, const std::vector &f) { std::vector g(m + 1, n + 1); for (uint t = 0; t < 1u << n; ++t) { g[f[t]] = std::min(g[f[t]], __builtin_popcount(t)); } for (size_t p = m; p; --p) { g[p - 1] = std::min(g[p - 1], g[p]); } return g; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); size_t n, m, k; std::cin >> n >> m >> k; std::vector s(m); for (size_t i = 0; i < m; ++i) { std::string si; std::cin >> si; for (size_t j = 0; j < n; ++j) { s[i] |= (si[j] - '0') << j; } } auto f = calc_f(n, m, k, s); auto g = calc_g(n, m, f); for (size_t p = 1; p <= m; ++p) { std::cout << g[p] << '\n'; } }