h,w,k=gets.split.map(&:to_i)
s=[]
l=1
h.times do
  s << gets.chomp.chars
  if s[-1].include?("#")
    f=false
    w.times do |j|
      if !f&&s[-1][j]=="."
        s[-1][j]=l
      elsif s[-1][j]=="#"
        s[-1][j]=l
        f=true if !f
        l+=1
      else
        s[-1][j]=s[-1][j-1]
      end
    end
  end
end
f=false
h.times do |i|
  if !f&&s[i][0]!="."
    i.times do |ii|
      s[ii]=s[i]
    end
    k=i
    f=true
  elsif s[i][0]!="."
    k=i
  else
    s[i]=s[k]
  end
end
h.times do |i|
  puts s[i].join(" ")
end
