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

cakearray=[]
answerarray=Array.new(h).map{Array.new(w,0)}
h.times{
    cakearray.push(gets.chomp.split(''))
}

number=1
i=0
h.times{
    if cakearray[i].include?('#')
        j=0
        rowcount=0
        w.times{
            if cakearray[i][j]=="#" && rowcount==0
                rowcount+=1
                answerarray[i][j]=number
            elsif cakearray[i][j]=="#"
                number+=1
                answerarray[i][j]=number
            else
                answerarray[i][j]=number
            end
            j+=1
        }
        number+=1
    end
    i+=1
}


k=0
h.times{
    if answerarray[k][0]==0
        k+=1
    else
        break
    end
}

answerarray[0]=answerarray[k]

m=1
(h-1).times{
   if answerarray[m][0]==0
        answerarray[m]=answerarray[m-1]  
   end
   m+=1 
}


answerarray.map{|value|
    puts value.join(" ")
}