str = gets.split
H,W,K = str[0].to_i, str[1].to_i, str[2].to_i
s = Array.new(H){Array.new(W)}
t = Array.new(H)

for i in 0...H do
    str = gets.chomp
    a = 0
    for j in 0...W do
        s[i][j] = str[j]
        if s[i][j] == "#"
            a += 1
        end
        t[i] = a
    end
end

start = 0
i = 0
while t[i] == 0
    start += 1
    i += 1
end

n = 0
for i in start...H do
    if t[i] == 0
        for j in 0...W do
            s[i][j] = s[i-1][j]
        end
    else
        m = 0
        n += 1
        for j in 0...W do
            if s[i][j] == "#"
                m += 1
                if m > 1
                    n += 1
                end
            end
            s[i][j] = n
        end
    end
end

for i in 0...start do
    for j in 0...W do
        s[i][j] = s[start][j]
    end
end

for i in 0...H do
    for j in 0...W do
        print s[i][j]," "
    end
    puts
end