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

    var num = 1
    var shouldCopyLater = 0
    ss.forEachIndexed { hIdx, row ->
        var found = false

        row.forEachIndexed { wIdx, s ->
            if (s == '.') {
                ans[hIdx][wIdx] = num
            }
            else if (s == '#' && !found) {
                found = true
                ans[hIdx][wIdx] = num
            }
            else if (s == '#' && found) {
                ans[hIdx][wIdx] = ++num
            }
        }

        if (found) {
            num++

            if (shouldCopyLater > 0) {
                for (i in 1..shouldCopyLater) {
                    ans[hIdx-i] = ans[hIdx]
                }
            }
            shouldCopyLater = 0

        } else {
            shouldCopyLater++
        }
    }

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

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