program main
implicit none
integer :: i, j, k, l, m, n
character(len=100) :: s(100), t
character(len=10000) :: res

read(*,*) n, l
do i = 1, n
   read(*,*) s(i)(1:l)
end do
do j = 1, n
do i = 2, n
   if( lle( s(i-1)(1:l), s(i)(1:l) ) .eqv. .false. ) then
      t(1:l)      = s(i)(1:l)
      s(i)(1:l)   = s(i-1)(1:l)
      s(i-1)(1:l) = t(1:l)
   end if
end do
end do
do i = 1, n
   do j = 1, l
      k = (i-1)*l +j
      res(k:k) = s(i)(j:j)
   end do
end do
write(*,*) res(1:n*l)


end program main

