h, w, k = gets.chomp.split.map(&:to_i)
s = []
h.times do
  s.push gets.chomp.split(//)
end

def ume(h, w, starty, startx, s, num)
  ue = 0 # max
  shita = h - 1 # max
  migi = w - 1 # max
  hidari = 0 # max

  # 1 line hidari
  (startx-1).downto(0) do |x|
    if s[starty][x] != '.'
      hidari = x + 1
      break
    end
  end
  # 1 line migi
  (startx+1).upto(w-1) do |x|
    if s[starty][x] != '.'
      migi = x - 1
      break
    end
  end
  # ue
  (starty-1).downto(0) do |y|
    unless (hidari..migi).to_a.all?{|x| s[y][x] == '.'}
      ue = y + 1
      break
    end
  end
  # shita
  (starty+1).upto(h-1) do |y|
    unless (hidari..migi).to_a.all?{|x| s[y][x] == '.'}
      shita = y - 1
      break
    end
  end

  # fill
  (ue..shita).each do |i|
    (hidari..migi).each do |j|
      s[i][j] = num.to_s
    end
  end
  # p [num, ' ', ue, shita, hidari, migi, ' ', starty, startx]
end

num = 1
h.times do |i|
  w.times do |j|
    if s[i][j] == '#'
      ume(h, w, i, j, s, num)
      num += 1
    end
  end
end

h.times do |i|
  puts s[i].join(' ')
end