h, w, k = gets.split.map(&:to_i)

count = 0

result = h.times.map {
  row = gets.chomp

  next nil unless row.include?('#')

  row.scan(/\.*#\.*/).flat_map { |chunk|
    count += 1
    [count.to_s] * chunk.size
  }.join(' ')
}

result.each_with_index do |row, index|
  next unless row.nil?

  result[index] = result[0..index].reverse_each.find { |row| row } ||
                  result[index..-1].find { |row| row }
end

puts result.join("\n")
