H, W, K = gets.split(' ').map(&:to_i)
cakes = []
H.times{cakes << gets.chomp.split('')}
result = []
count = 1
prev_row = []
blank_rows = []
cakes.each_with_index do |row, h|
  result_row = []
  if row.all?{|p| p == '.'} && h == 0
	blank_rows << h
  elsif row.all?{|p| p == '.'}
    result << prev_row
  else
    if row.one?{|p| p == '#'}
      result_row = Array.new(W).fill(count)
      result << result_row
      count += 1
    else
      last_strawberry = row.count('#')
      strawberry = 1
      row.each_with_index do |p, w|
        if p == '.'
          result_row << count
        elsif p == '#'
          if strawberry == last_strawberry
            result_row << count
          else
            result_row << count
            count += 1
          end
          strawberry += 1
        end
        count += 1 if w == W - 1
      end
      result << result_row
    end
    prev_row = result_row
    unless blank_rows.empty?
      blank_rows.size.times{result.unshift(result_row)}
      blank_rows = []
    end
  end
end
result.each do |row|
  puts row.join(' ')
end