import sys readline = sys.stdin.readline popcnt = [0] * (2 ** 12) for t in range(1, 2 ** 12): popcnt[t] = 1 + popcnt[t & (t - 1)] MASK_32 = 2 ** 32 - 1 n, m, k = map(int, readline().split()) 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] f = [0] * (2 ** n) for i in range(m): # reversed, but it's ok s = int(readline(), 2) f[s] += 1 a = [0] * (n + 1) for l in range(k, n + 1): a[l] = binom[l - 1][l - k] if a[l] and ((l - k) & 1): a[l] = MASK_32 - a[l] # supset zeta b = 1 while b < 2 ** n: for l in range(0, 2 ** n, 2 * b): for p in range(l, l + b): f[p] += f[p + b] b *= 2 for t in range(2 ** n): f[t] = (f[t] * a[popcnt[t >> 12] + popcnt[t & 0xfff]]) & MASK_32 # subset zeta b = 1 while b < 2 ** n: for l in range(0, 2 ** n, 2 * b): for p in range(l, l + b): f[p + b] += f[p] b *= 2 g = [n + 1] * (m + 1) for t in range(2 ** n): f[t] &= MASK_32 g[f[t]] = min(g[f[t]], popcnt[t >> 12] + popcnt[t & 0xfff]) for p in reversed(range(m)): g[p] = min(g[p], g[p + 1]) print('\n'.join(map(str, g[1:])))