fun main(args :Array<String>) {
    val (h, w, k) = readIntegerList()
    var count = 0
    val map = Array(h) { IntArray(w) { 0 } }
    for (i in 0 until h) {
        val tmp = readLine()!!.toCharArray()

        if (!(tmp.contains('#'))) {
            continue
        }

        count++
        var aa = false
        for (j in 0 until w) {
            map[i][j] = if (tmp[j] == '.') {
                count
            } else {
                if (aa) {
                    count++
                }
                aa = true
                count
            }
        }
    }

    // for (i in 0 until h) {
    //     val tmp = map[i].map(Int::toString).joinToString(" ")
    //     println(tmp)
    // }
    // println()

    for (i in 0 until h) {
        if (map[i][0] != 0) {
            var j = i - 1
            while (j >= 0 && map[j][0] == 0) {
                map[j] = map[i]
                j--
            }
        }
    }

    for (i in (h - 1) downTo 0) {
        if (map[i][0] != 0) {
            var j = i + 1
            while (j < h && map[j][0] == 0) {
                map[j] = map[i]
                j++
            }
        }
    }


    for (i in 0 until h) {
        val tmp = map[i].map(Int::toString).joinToString(" ")
        println(tmp)
    }
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
