H, W, K = gets.split.map &:to_i
i = 1
s = gets(p)
s << "\n" if s[-1] != "\n"
s.gsub!(/\.*#\.*/){
    ("#{i} " * $&.size).tap{ i += 1 }
}
# puts s
s.gsub!(/(\.+\n)*([0-9 ]+\n)(\.+\n)*/){
  $2 * $&.count("\n")
}
puts s
