import sequtils import strutils import algorithm const N_MAX: int = 24 const HALF_N_MAX: int = (N_MAX + 1) div 2 const MASK_HALF_N_MAX = (1 shl HALF_N_MAX) - 1 var binom: array[N_MAX + 1, array[N_MAX + 1, int]] for i in 0 .. N_MAX: binom[i][0] = 1 for j in 1 .. i: binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j] var popcnt: array[1 shl HALF_N_MAX, int] for t in 1 ..< 1 shl HALF_N_MAX: popcnt[t] = 1 + popcnt[t and (t - 1)] var n, m, k: int var nmk = stdin.readLine.split.map parseInt n = nmk[0] m = nmk[1] k = nmk[2] var f = newSeq[int](1 shl n) for i in 0 ..< m: # reversed, but it's ok let s = stdin.readLine var x = 0 for j in 0 ..< n: x += int(s[j] == '1') shl j f[x] += 1 var a = newSeq[int](n + 1) for l in k .. n: a[l] = binom[l - 1][l - k] if bool((l - k) and 1): a[l] = -a[l] # supset zeta proc supset_zeta(): void = var b = 1 while b < 1 shl n: for l in countup(0, (1 shl n) - 1, 2 * b): for p in l ..< l + b: f[p] += f[p + b] b *= 2 supset_zeta() for t in 0 ..< 1 shl n: f[t] *= a[popcnt[t shr HALF_N_MAX] + popcnt[t and MASK_HALF_N_MAX]] # subset zeta f.reverse supset_zeta() f.reverse var g = newSeq[int](m + 1) for i in 0 .. m: g[i] = n for t in 0 ..< 1 shl n: g[f[t]] = min(g[f[t]], popcnt[t shr HALF_N_MAX] + popcnt[t and MASK_HALF_N_MAX]) for p in countdown(m - 1, 0): g[p] = min(g[p], g[p + 1]) for p in 1 .. m: echo g[p]