H, W, K = gets.split.map(&:to_i)

cake = H.times.map { gets.chomp.chars }
AREA = Array.new(H) { Array.new(W, -1) }

cnt = 0

H.times do |y|
  W.times do |x|
    c = cake[y][x]

    next if c != '#'
    cnt += 1

    AREA[y][x] = cnt
  end
end

require 'pp'
# pp AREA

def check_right
  H.times do |y|
    id = -1

    W.times do |x|
      if AREA[y][x] != -1
        id = AREA[y][x]
      end

      AREA[y][x] = id
    end
  end
end

def check_left
  (H - 1).downto(0) do |y|
    id = -1

    (W - 1).downto(0) do |x|
      if AREA[y][x] != -1
        id = AREA[y][x]
      end

      AREA[y][x] = id
    end
  end
end

def check_down
  visited = Hash.new(false)

  H.times do |y|
    W.times do |x|
      id = AREA[y][x]

      next if id == -1
      next if visited[id]

      visited[id] = true
      from = to = x

      (x + 1).upto(W - 1) do |nx|
        break if id != AREA[y][nx]

        to = nx
      end

      (y + 1).upto(H - 1) do |ny|
        break unless all_empty?(ny, from, to)

        update_area(ny, from, to, id)
      end
    end
  end
end

def check_up
  visited = Hash.new(false)

  (H - 1).downto(0) do |y|
    0.upto(W - 1) do |x|
      id = AREA[y][x]

      next if id == -1
      next if visited[id]

      visited[id] = true
      from = to = x

      (x + 1).upto(W - 1) do |nx|
        break if id != AREA[y][nx]

        to = nx
      end

      (y - 1).downto(0) do |ny|
        break unless all_empty?(ny, from, to)

        update_area(ny, from, to, id)
      end
    end
  end
end

def all_empty?(y, from, to)
  AREA[y][from..to].all? { |x| x == -1 }
end

def update_area(y, from, to, id)
  from.upto(to) do |x|
    AREA[y][x] = id
  end
end

require 'pp'

check_right
check_left
check_down
check_up

puts AREA.map { |row| row.join(' ') }
