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_20 = 2 ** 20 - 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] = (2 ** 20) - a[l] # supset zeta b1 = 1 while b1 < 2 ** n: for l in range(0, 2 ** n, 2 * b1): for p in range(l, l + b1): f[p] += f[p + b1] b1 *= 2 for t in range(2 ** n): f[t] &= MASK_20 f[t] = (f[t] * a[popcnt[t >> 12] + popcnt[t & 0xfff]]) & MASK_20 # subset zeta b2 = 1 while b2 < 2 ** n: for l in range(0, 2 ** n, 2 * b2): for p in range(l, l + b2): f[p + b2] += f[p] b2 *= 2 g = [n + 1] * (m + 1) for t in range(2 ** n): f[t] &= MASK_20 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:])))