program Strawberry_Cakes
  implicit none
  integer :: h, w, k, i, j, x
  integer, dimension(300,300) :: a = 0, b = 0
  character(300) :: s
  read(*,*) h, w, k
  do i = 1, h
    read(*,*) s
    do j = 1, w
      if (s(j:j) == "#") a(i,j) = 1
    end do
  end do
  k = 0
  do j = 1, w
    x = 0
    do i = 1, h
      if (a(i,j) == 0) cycle
      k = k+1
      b(x+1:h,j:w) = k
      x = i
    end do
  end do
  if (b(1,1) == 0) then
    do j = 1, w
      if (b(1,j) == 0) cycle
      do i = 1, h
        b(i,1:j-1) = b(i,j)
      end do
      exit
    end do
  end if
  do i = 1, h
    write(*,'(i0)',advance='no') b(i,1)
    do j = 2, w
      write(*,'(x,i0)',advance='no') b(i,j)
    end do
    write(*,*)
  end do
end program Strawberry_Cakes