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

m = Array.new(H) { Array.new(W,0) }

blank = []
idx = 1
H.times do |i|
    s = gets.chomp
    l = 0
    r = s.index('#',l)
    unless r
        blank << i
        next
    end

    while r = s.index('#',l)
        m[i].fill(idx,l..r)
        idx += 1
        l = r+1
    end
    idx -= 1
    m[i].fill(idx,l..-1)
    idx += 1

    blank.each do |j|
        m[j] = m[i]
    end
    blank = []
end

if !blank.empty?
    i = H-1
    i -= 1 while m[i][0] == 0
    blank.each do |j|
        m[j] = m[i]
    end
end

m.each do |row|
    puts row.join(' ')
end
