h, w, k = gets.split.map(&:to_i)

ans = Array.new(h){Array.new(w)}
now = 0
a = false

h.times do |i|
    s = gets.chomp

    if !s.include?("#")
        i == 0 ? a = true : ans[i] = ans[i-1]
    else
        now += 1
        b = false
        s.each_char.with_index do |c, j|
            if c == "#"
                now += 1 if b
                b = true
            end
            ans[i][j] = now
        end
    end
end

ans[0] = ans[1] if a
puts ans.map{|e| e.join(" ")}