fun main(args : Array<String>) {
    val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
    val cake = Array(h){ readLine()!!}

    val ans = Array(h){ IntArray(w) { 0 } }
    var num = 1
    var copy = 0
    repeat(h) { hIdx ->
        var berry = false

        repeat(w) { wIdx ->
            val c = cake[hIdx][wIdx]
            if (c == '#') {
                if (berry) num++
                berry = true
            }
            ans[hIdx][wIdx] = num
        }

        if (!berry) {
            copy++
        }  else {
            for (i in hIdx-copy until hIdx) {
                ans[i] = ans[hIdx]
            }
            copy = 0
            num++
        }
    }

    if (copy > 0) {
        for (i in h-copy until h) {
            ans[i] = ans[h-copy-1]
        }
    }

    ans.forEach { println(it.joinToString(separator = " "))}
}