h,w,k = gets.split.map(&:to_i)
a = []
h.times {a << gets.chomp!.split("")}

ans = Array.new(h){Array.new(w,0)}
l = 0
t = false

num = 0
h.times do |i|
    if a[i].include?('#')
        t = true
        count = 0
        w.times do |j|
            count += 1 if a[i][j] == '#'
            ans[i][j] = num + (count == 0 ? 1 : count)
        end
        num += count
    elsif t
        ans[i] = ans[i-1]
    else
        l += 1
    end
end

(l-1).downto(0) do |i|
    ans[i] = ans[i+1]
end

puts ans.map{|e| e.join(" ")}