fun main(args: Array<String>) {
    val (H, W, K) = readLine()!!.split(" ").map(String::toInt)
    val F = Array(H) { readLine()!!.toCharArray() }
    val ans = Array(H) { Array(W) { 0 } }
    var p = 1
    for (i in 0..H-1) {
        if (F[i].filter{ x -> x == '#'}.count() != 0) {
            var first = true
            for (j in 0..W-1) {
                if (F[i][j] == '#') {
                    if (!first) { p += 1 }
                    first = false
                }
                ans[i][j] = p
            }
            p += 1
        }
    }
    for (i in 1..H-1) {
        if (F[i].filter { x -> x == '#' }.count() == 0) {
            ans[i] = ans[i-1]
        }
    }
    for (i in (H-2).downTo(0)) {
        if (F[i].filter { x -> x == '#' }.count() == 0) {
            ans[i] = ans[i+1]
        }
    }
    ans.forEach { l -> l.forEach{ s -> print("$s ") }; println() }
}