program DISCO2020yC
integer::H,W,K
integer,allocatable::ans(:,:)
character(300)reader
integer ichigonumber
read*,H,W,K
allocate(ans(H,W))
ans=-1
ichigonumber=1
do i=1,H
    read*,reader
    do j=1,W
        if(reader(j:j)=="#")then
            ans(i,j)=ichigonumber
            ichigonumber=ichigonumber+1
        endif
    end do
end do
do i=1,H
    do j=1,W
        if(ans(i,j)==-1)then
            if(j==1)cycle
            if(ans(i,j-1)>0)then
                ans(i,j)=ans(i,j-1)
            endif
        endif
    end do
    do j=W,1,-1
        if(ans(i,j)==-1)then
            if(j==W)cycle
            if(ans(i,j+1)>0)then
                ans(i,j)=ans(i,j+1)
            endif
        endif
    end do
end do
do i=1,H
    if(ans(i,1)<0)then
        if(i==1)cycle
        if(ans(i-1,1)>0)then
            ans(i,:)=ans(i-1,:)
        endif
    endif
end do
do i=H,1,-1
    if(ans(i,1)<0)then
        if(i==H)cycle
        if(ans(i+1,1)>0)then
            ans(i,:)=ans(i+1,:)
        endif
    endif
end do
do i=1,H
    write(*,"(i0)",advance="no") ans(i,1)
    do j=2,W
        write(*,"(A,i0)",advance="no")" ",ans(i,j)
    end do
    write(*,*)
end do
end