h, w, _ = gets.split.map(&:to_i)
s = Array.new(h){gets.chomp.chars}
a = Array.new(h){Array.new(w, 0)}
k = 0
h.times do |i|
  k += 1
  x = 0
  f = true
  w.times do |j|
    if s[i][j] == '#' && f
      f = false
      x.upto(j) do |y|
        a[i][y] = k
      end
      x = j + 1
    elsif s[i][j] == '#' && f == false
      k += 1
      a[i][j] = k
      x = j + 1
    else
      k += 1 if f == false
      f = true
    end
  end
  if s[i][-1] == '.'
    k -= 1
    x.upto(w - 1) do |y|
      a[i][y] = k
    end
  end
end
y = 0
f = true
h.times do |i|
  if s[i].all?{|x| x == '.'} && f
    y = i
    f = false
  elsif s[i].any?{|x| x =='#'} && f == false
    y.upto(i.pred) do |z|
      a[z] = a[i]
    end
    f = true
  end
end
y = 0
f = true
h.pred.downto(1) do |i|
  if s[i].all?{|x| x == '.'} && f
    y = i
    f = false
  elsif s[i].any?{|x| x == '#'} && f == false
    y.downto(i.next) do |z|
      a[z] = a[i]
    end
    f = true
  end
end
h.times do |i|
  puts a[i].join(' ')
end