fun main(args: Array<String>) {
    ddcc2020qualc()
}

private enum class Direction { R, L }

fun ddcc2020qualc() {
    val (h, w, k) = readLine()!!.split(' ').map { it.toInt() }
    val board = (1..h).map { readLine()!! }

    val berrys = mutableListOf<Pair<Int, Int>>()

    board.forEachIndexed { indexY, s ->
        s.forEachIndexed { indexX, c ->
            if (c == '#') berrys.add(Pair(indexY, indexX))
        }
    }

    val answer = Array(h) { IntArray(w) { 0 } }

    berrys.forEachIndexed { index, pair ->
        answer[pair.first][pair.second] = index + 1
    }

    fun dfs(y: Int, x: Int, value: Int, direction: Direction) {
        when (direction) {
            Direction.R -> {
                if (x + 1 <= w - 1 && (answer[y][x + 1] == 0 || answer[y][x + 1] == value)) {
                    answer[y][x + 1] = value
                    dfs(y, x + 1, value, Direction.R)
                }
            }
            Direction.L -> {
                if (x - 1 >= 0 && (answer[y][x - 1] == 0 || answer[y][x - 1] == value)) {
                    answer[y][x - 1] = value
                    dfs(y, x - 1, value, Direction.L)
                }
            }
        }
    }

    berrys.forEachIndexed { index, pair ->
        val (y, x) = pair
        dfs(y, x, index + 1, Direction.R)
    }
    berrys.forEachIndexed { index, pair ->
        val (y, x) = pair
        dfs(y, x, index + 1, Direction.L)
    }

    var berryFound = false
    for (yi in 0 until h) {
        val row = answer[yi]
        if (row.none { it != 0 }) continue

        if (!berryFound) {
            (0 until yi).forEach { answer[it] = row.copyOf() }
            berryFound = true
        }

        var down = yi
        while (down + 1 < h && answer[down + 1].none { it != 0 }) down++
        if (down < h) {
            (yi..down).forEach { answer[it] = row.copyOf() }
        }
    }

    val ans = answer.joinToString(System.lineSeparator()) { it.joinToString(" ") }

    println(ans)
}
