local h,w,k=io.read("n","n","n","l")
local cake={}
local counter=1
for i=1,h do
    local s=io.read()
    local strawberry=0
    for _,_ in s:gmatch("#") do
        strawberry=strawberry+1
    end
    cake[i]={}
    if strawberry>0 then
        for j=1,w do
            if s:sub(j,j)~="#" then
                cake[i][j]=counter
            else
                cake[i][j]=counter
                strawberry=strawberry-1
                if strawberry>0 then
                    counter=counter+1
                end
            end
        end
        counter=counter+1
    end
end

for i=1,h do
    if #cake[i]==0 then
        print(table.concat((cake[i-1] or cake[i+1])," "))
    else
        print(table.concat(cake[i]," "))
    end
end