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

ans = Array.new(h){Array.new(w)}
now = 0
arr = []

h.times do |i|
    s = gets.chomp
    x = s.index("#")
    
    if x.nil?
        i == 0 || ans[i-1][0].nil? ? arr.unshift(i) : ans[i] = ans[i-1]
    else
        now += 1
        ans[i].fill(now, 0..x)
        (x+1).upto(w-1) do |j|
            now += 1 if s[j] == "#"
            ans[i][j] = now
        end
    end
end

arr.each {|i| ans[i] = ans[i+1]}
puts ans.map{|e| e.join(" ")}