h, w, k = gets.split.map(&:to_i)
s = h.times.map { gets.chomp }
a = h.times.map { Array.new(w, 0) }
kk = 0
exist = false
skip = 0
for i in 0...h do
  if s[i].include?("#")
    exist = true
    j = 0
    while true do
      p = s[i].index("#", j)
      if !p.nil?
        kk += 1
        for jj in j..p do
          a[i][jj] = kk
        end
        j = p + 1
      else
        for jj in j...w do
          a[i][jj] = kk
        end
        break
      end
    end
  else
    if exist
      for jj in 0...w do
        a[i][jj] = a[i-1][jj]
      end
    else
      skip += 1
    end
  end
end
for i in 0...skip do
  for jj in 0...w do
    a[i][jj] = a[skip][jj]
  end
end
for i in 0...h do
  puts a[i].join(" ")
end
