require 'pp'
h,w,k = gets.split.map(&:to_i)

s = []
h.times do
  s << gets.chomp.chars
end
# pp s
# puts s.map(&:join).join("\n")


c = Array.new(h){Array.new(w,0)}
num = 1
h.times do |hh|
  w.times do |ww|
    if s[hh][ww] == "#"
      c[hh][ww] = num
      num += 1
      filled = true
    else
      c[hh][ww] = num
      filled = false
    end
    if ww = w-1 && filled = false
      www = ww
      while c[hh][www] == num-1
        c[hh][www] = num-1
        www -= 1
      end
    end
  end
end
puts c.map{|cc|cc.join(' ')}.join("\n")
