# after listening explanation
h, @w, k = gets.split.map(&:to_i)
@s = $<.map{|l|l.chomp.chars.map{|c|c=="#"}}
@a = [*0..h-1].map{Array.new(@w,-1)}
@counter = 1
flag_h = -1
from_h = 0
def separate(start, goal, target)
  flag_w = -1
  from_w = 0
  @w.times{|j|
    if @s[target][j]
      if flag_w>=0
        [*start..goal].each{|x| [*from_w..j-1].each{|y| @a[x][y]=@counter} }
        @counter+=1
        from_w = j
      end
      flag_w = j
    end
    if j==@w-1
      [*start..goal].each{|x| [*from_w..j].each{|y| @a[x][y]=@counter} }
      @counter+=1
    end
  }
end
h.times{|i|
  if @s[i].include?(true)
    if flag_h>=0
      separate(from_h, i-1, flag_h)
      from_h = i
    end
    flag_h = i
  end
  if i==h-1
    separate(from_h, i, flag_h)
  end
}
puts @a.map{|ai|ai.join(" ")}.join("\n")
