input = gets.chomp.split(" ").map(&:to_i)

H = input[0]
W = input[1]
K = input[2]
dic = 1
copy_count = 0
res_line = Array.new(W)

H.times do
  line = gets.chomp.split("")
  count = line.count("#")
  if count == 0
    copy_count += 1
    next
  end
  

  counter = 1
  line.each_with_index do |e,i|

    if e == "." || counter == count
      res_line[i] = dic
    elsif e == "#"
      res_line[i] = dic
      dic += 1
      counter += 1
    end
  end
  dic += 1
  copy_count += 1
  copy_count.times do
    puts res_line.join(" ")
  end
  copy_count = 0
end


if copy_count != 0
  copy_count.times do
    puts res_line.join(" ")
  end
end
