fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main() {
    val (h, w, k) = intList()
    val hw = Array(h) { readLine()?.toCharArray()?.map { it.toString() }?.toTypedArray() ?: return }
    val emptyLines = Array(h) {
        hw[it].all { it == "." }
    }
    var index = 1
    0.until(h).forEach { i ->
        0.until(w).forEach { j ->
            if (hw[i][j] == "#") {
                // 左右
                val kName = index.toString()
                hw[i][j] = kName
                var l = 1
                while (j - l >= 0) {
                    if (hw[i][j - l] == ".") {
                        hw[i][j - l] = kName
                    } else {
                        break
                    }
                    l++
                }
                var r = 1
                while (j + r < w) {
                    if (hw[i][j + r] == ".") {
                        hw[i][j + r] = kName
                    } else {
                        break
                    }
                    r++
                }

                // 上下
                var u = 1
                while (i - u >= 0) {
                    if (emptyLines[i - u] && hw[i - u][j] == ".") {
                        hw[i - u][j] = kName
                        1.until(l).forEach {
                            hw[i - u][j - it] = kName
                        }
                        1.until(r).forEach {
                            hw[i - u][j + it] = kName
                        }
                    } else {
                        break
                    }
                    u++
                }
                var d = 1
                while (i + d < h) {
                    if (emptyLines[i + d] && hw[i + d][j] == ".") {
                        hw[i + d][j] = kName
                        1.until(l).forEach {
                            hw[i + d][j - it] = kName
                        }
                        1.until(r).forEach {
                            hw[i + d][j + it] = kName
                        }
                    } else {
                        break
                    }
                    d++
                }
                index++
            }
        }
    }
    buildString {
        hw.forEach {
            appendln(it.joinToString(" "))
        }
    }.let {
        println(it.trimIndent())
    }
}
