from typing import List def supset_zeta(f: List[int]): n = len(f) b = 1 while b < n: l = 0 while l < n: for p in range(l, l + b): f[p] += f[p + b] l += 2 * b b *= 2 def subset_zeta(f: List[int]): n = len(f) b = 1 while b < n: l = 0 while l < n: for p in range(l, l + b): f[p + b] += f[p] l += 2 * b b *= 2 N_MAX = 20 popcnt = [0] * (1 << N_MAX) for t in range(1, 1 << N_MAX): popcnt[t] = 1 + popcnt[t & (t - 1)] def calc_f(n: int, m: int, k: int, s: List[int]): binom = [[0] * (n + 1) for _ in range(n + 1)] for i in range(n + 1): binom[i][0] = 1 for j in range(1, i + 1): binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j] a = [0] * (n + 1) for l in range(k, n + 1): a[l] = 1 for i in range(k, l): a[l] -= a[i] * binom[l][i] f = [0] * (1 << n) for u in s: f[u] += 1 supset_zeta(f) for t in range(1 << n): if popcnt[t] < k: f[t] = 0 else: f[t] *= a[popcnt[t]] subset_zeta(f) return f def calc_g(n: int, m: int, f: List[int]): g = [n + 1] * (m + 1) for t in range(1 << n): g[f[t]] = min(g[f[t]], popcnt[t]) for p in reversed(range(m)): g[p] = min(g[p], g[p + 1]) return g if __name__ == '__main__': n, m, k = map(int, input().split()) s = [0] * m for i in range(m): si = input() for j in range(n): s[i] |= (ord(si[j]) - ord('0')) << j f = calc_f(n, m, k, s) g = calc_g(n, m, f) print(*g[1:], sep='\n')