require 'pp'
     
h, w, k = gets.chomp!.split(" ").map(&:to_i)
cake = []
pos_x = {}
pos_y = {}
h.times do |i|
    chs = gets.chomp!.chars
    cake << chs
    chs.each_with_index do |ch, j|
        if ch == "#"
            pos_x[j] ||= {}
            pos_y[i] ||= {}
            pos_y[i][j] = 1
            pos_x[j][i] = 1
        end
    end
end
 
ans = []
pass_rows = []
index = 1
h.times do |j|
    w.times do |i|
        ans[j] ||= []
        next if ans[j][i] && cake[j][i] == "."
        
        if pos_y[j].nil?
            pass_rows << j
            ans[j] = Array.new(w, -1)
            break
        end
        ans[j][i] = index
        # 今自分がいちご
        if cake[j][i] == "#"
            # みぎの次のいちごまで全部ぬりきう
            if cake[j]
                tmp = i + 1
                while cake[j][tmp] == "."
                    ans[j][tmp] = index
                    tmp += 1
                end
            end
            index += 1
        # 自分はいちごでないが→にいちごがある
        elsif cake[j]
            tmp = i + 1
            while cake[j][tmp] != "#" && cake[j][tmp] != nil
                ans[j][tmp] = index
                tmp += 1
            end
            ans[j][tmp] = index
        end
    end
end

pass_rows.each do |row_num|
    merge_index = row_num == 0 ? 1 : row_num - 1

    w.times do |x|
        ans[row_num][x] = ans[merge_index][x]
    end
end
 
ans.each do |x|
    puts x.join(" ")
end
