program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w,k,x,y,num,l
    integer(int32), allocatable:: ans(:,:)
    character(1),allocatable:: s(:,:)
    logical:: exist, exist2

    read*, h,w,k
    allocate(s(w,h), ans(w,0:h))
    ans(:,0) = 1
    block
        character(w):: inpt_s
        do y=1,h
            read*, inpt_s
            do x=1,w
                s(x,y) = inpt_s(x:x)
            end do
        end do
    end block
    
    num=1
    do y=1,h
        exist = .false.
        exist2 = .false.
        do x=1,w
            if (s(x,y) == '#' .and. exist) exist2 = .true.
            if (s(x,y) == '#') exist = .true.
        end do

        if (.not. exist) then
            ans(:,y) = ans(:,y-1)
            cycle
        end if

        if (.not. exist2) then
            ans(:,y) = num
            num=num+1
            cycle
        end if
        l=1
        do x=1,w
            if (s(x,y) == '#') then
                ans(l:x,y) = num
                l = x+1
                num=num+1
            end if
        end do
        if (l <= w) then
            ans(l:w,y) = num-1
        end if
    end do

    do y=1,h
        print'(*(i0,1x))', ans(:,y)
    end do
end program main