h,w,k = gets.split.map &:to_i
cake = Array.new(h) { gets.chomp }
cut = Array.new(h) { [0] * w }

num = 1
top = 0
left = 0
fill = false

h.times do |i|
  w.times do |j|
    if cake[i][j] == "#"
      fill = true
      top.upto(i) do |y|
        left.upto(j) do |x|
          cut[y][x] = num
        end
      end
      left = j + 1
      num += 1
    elsif j == w - 1
      if fill
        top.upto(i) do |y|
          left.upto(j) do |x|
            cut[y][x] = num - 1
          end
        end
      end
    end
  end
  top = i + 1 if fill
  fill = false
  left = 0
end

unless fill
  top.upto(h-1) do |y|
    0.upto(w-1) do |x|
      cut[y][x] = cut[y-1][x]
    end
  end
end

h.times do |y|
  puts cut[y].join(" ")
end

