import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class Main { static final int MAX_N = 24; static final int MAX_HALF_N = (MAX_N + 1) / 2; static final int MASK_HALF_N = (1 << MAX_HALF_N) - 1; public static void main(String[] args) { var sc = new Scanner(System.in); final int n = Integer.parseInt(sc.next()); final int m = Integer.parseInt(sc.next()); final int k = Integer.parseInt(sc.next()); var f = new int[1 << n]; for (int i = 0; i < m; ++i) { var s = sc.next(); int x = 0; for (int j = 0; j < n; ++j) { x |= (s.charAt(j) - '0') << j; } ++f[x]; } sc.close(); var binom = new int[n + 1][n + 1]; for (int i = 0; i <= n; ++i) { binom[i][0] = 1; for (int j = 1; j <= i; ++j) binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j]; } var a = new int[n + 1]; for (int l = k; l <= n; ++l) { a[l] = 1; for (int i = k; i < l; ++i) a[l] -= a[i] * binom[l][i]; } for (int b = 1; b < 1 << n; b *= 2) for (int l = 0; l < 1 << n; l += 2 * b) for (int p = l; p < l + b; ++p) { f[p] += f[b + p]; } var popc = new int[1 << MAX_HALF_N]; for (int i = 1; i < 1 << MAX_HALF_N; ++i) { popc[i] = 1 + popc[i & (i - 1)]; } for (int i = 0; i < 1 << n; ++i) { f[i] *= a[popc[i & MASK_HALF_N] + popc[i >> MAX_HALF_N]]; } for (int b = 1; b < 1 << n; b *= 2) for (int l = 0; l < 1 << n; l += 2 * b) for (int p = l; p < l + b; ++p) { f[b + p] += f[p]; } var g = new int[m + 1]; Arrays.fill(g, n); for (int t = 0; t < 1 << n; ++t) { g[f[t]] = Math.min(g[f[t]], popc[t & MASK_HALF_N] + popc[t >> MAX_HALF_N]); } for (int p = m - 1; p >= 0; --p) { g[p] = Math.min(g[p], g[p + 1]); } var pw = new PrintWriter(System.out); for (int p = 1; p <= m; ++p) { pw.println(g[p]); } pw.flush(); pw.close(); } }