fun main(args: Array<String>) {
    val (H, W, K) = readInputLine().split(" ").map { it.toInt() }
    val cake = Array(H) { readInputLine().toCharArray() }
    val containsStrawberry = BooleanArray(H) { cake[it].contains('#') }
    
    val ans = Array(H) { IntArray(W) }

    var now = 1
    var cakeDetected = false

    for (i in 0 until H) {
        if (!containsStrawberry[i]) {
            continue
        }
        cakeDetected = false
        for (j in 0 until W) {
            if (cake[i][j] == '#') {
                if (!cakeDetected) {
                    cakeDetected = true
                } else {
                    now++
                }
            }
            ans[i][j] = now
        }
        now++
    }
    
    var topDetected = false
    
    for (i in 0 until H) {
        if (containsStrawberry[i]) {
            if (!topDetected) {
                topDetected = true
                for (j in 0 until i) {
                    ans[j] = ans[i].copyOf()
                }
            }
        } else {
            if (topDetected) {
                ans[i] = ans[i - 1].copyOf()
            }
        }
    }

    for (a in ans) {
        println(a.joinToString(" "))
    }
}

fun readInputLine(): String {
    return readLine()!!
}
