import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val H, W, K = in.next().toInt
  val s = new Array[String](H)
  for (i <- 0 until H) {
    s(i) = in.next()
  }


  //
  var color = 1
  var flag = false
  var rowFlag = false
  var rowVol = 1
  var ans = Array.ofDim[Int](H, W)
  for (y <- 0 until H) {
    for (x <- 0 until W) {
      if (s(y)(x) == '#') {
        rowFlag = true

        if (!flag) {
          flag = true
        }
        else {
          color += rowVol
          rowVol = 1
        }
      }

      ans(y)(x) = color
    }


    // カラー潰し
    if (!rowFlag) {
      for (x <- 0 until W) {
        ans(y)(x) = -1
      }
    }


    // 折り返し
    if (rowFlag && color != K) {
      if (rowVol == 1)
        color += 1

      rowVol = 0
    }

    rowFlag = false
  }



  // 塗り分け
  for (x <- 0 until W) {
    var hoge = -1
    for (y <- 0 until H) {
      if (ans(y)(x) == -1)
        ans(y)(x) = hoge
      else {
        hoge = ans(y)(x)
      }
    }
  }

  for (x <- 0 until W) {
    var hoge = -1
    for (y <- (0 until H).reverse) {
      if (ans(y)(x) == -1)
        ans(y)(x) = hoge
      else {
        hoge = ans(y)(x)
      }
    }
  }



  // print
  for (y <- 0 until H) {
    pw.println(ans(y).mkString(" "))
  }

  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
