n, m, k = map(int, input().split()) PC = [0] * (1 << 12) for i in range(1, 1 << 12): p = i & -i PC[i] = PC[i ^ p] + 1 dp = [0] * (1 << n) for _ in range(m): S = int(input(), 2) dp[S] += 1 for i in range(n): dbit = 1 << i for s in range(0, 1 << n, 2 * dbit): for j in range(s, s + dbit): dp[j] += dp[dbit + j] nCk = [[0] * (n + 1) for _ in range(n + 1)] nCk[0][0] = 1 for i in range(1, n + 1): nCk[i][0] = 1 for j in range(1, i + 1): nCk[i][j] = nCk[i - 1][j - 1] + nCk[i - 1][j] C = [0] * (n + 1) C[k] = 1 for i in range(k + 1, n + 1): C[i] = 1 for j in range(i): C[i] -= C[j] * nCk[i][j] for bit in range(1 << n): p = PC[bit >> 12] + PC[bit & 4095] dp[bit] *= C[p] for i in range(n): dbit = 1 << i for s in range(0, 1 << n, 2 * dbit): for j in range(s, s + dbit): dp[dbit + j] += dp[j] ans = [n] * m for bit in range(1 << n): c = dp[bit] - 1 if c >= 0: p = PC[bit >> 12] + PC[bit & 4095] ans[c] = min(ans[c], p) for i in range(m - 2, -1, -1): ans[i] = min(ans[i], ans[i + 1]) print(*ans, sep="\n")