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|
  next if s[hh].all?{|ss|ss == '.'}
  w.times do |ww|
    if s[hh][ww] == "#"
      num += 1
      c[hh][ww] = num
      filled = true
    else
      c[hh][ww] = num
      filled = false
    end
    if ww == w-1 && !filled
      www = w-1
      until c[hh][www] == num-1
        c[hh][www] = num-1
        www -= 1
      end
    end
  end
end

h.times do |hh|
  w.times do |ww|
    if c[hh][ww] == 0
      hhh = hh
      until c[hhh][ww] != 0
        hhh += 1
        if hhh >= h
          until (hhh < h) && c[hhh][ww] != 0
            hhh -= 1
          end
          break
        end
      end
      n = c[hhh][ww]
      c[hh][ww] = n
    end
  end
end

puts c.map{|cc|cc.join(' ')}.join("\n")
