      MODULE strQsortMod
! 文字列のクイックソート
! charLen で使用可能な文字列サイズの上限を定める．

!!!!!!!!!!!!!!!!!!!  caution  !!!!!!!!!!!!!!!!!!!
! 大文字小文字を併用する場合に注意！！！！
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      implicit none
      integer(4),parameter,private :: charLen = 10
      
      interface qSort
        module procedure :: strQsort
      end interface
      
      contains
      pure recursive function strQsort( s ) result( r )
        implicit none
        character(charLen), intent(in) :: s(:)
        character(charLen) :: r( size(s) ), sample(3), buffer
        integer(4) :: len, i,j
        
        len = size( s(:) )
        if( len<=1 )then
          r = s
        else
          !select pivot
          sample(1:3) = [s(1), s(len/2), s(len)]
          do i = 1,2
            do j = 2,3
              if( sample(i)>sample(j) )then
                buffer = sample(i)
                sample(i) = sample(j)
                sample(j) = buffer
              end if
            end do
          end do
          
          r = [ strQsort( pack(s(:), s(:)< sample(2)) ), &
                          pack(s(:), s(:)==sample(2))  , &
                strQsort( pack(s(:), s(:)> sample(2)) ) ]
        end if
      end function
      end MODULE strQsortMod

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      module piyoMod
      implicit none
      type pair
        integer :: n
        character(10) :: s
      end type
      
      contains
      recursive function sortP( p ) result( r )
      !問題文よく見たら必要なかった
        implicit none
        type(pair),intent(in) :: p(:)
        type(pair) :: r( size(p) )
        integer(16) :: len,samp(3), i,j,b
        
        len = size( p )
        if( len<=1 )then
          r = p
        else
          samp = [p(1)%n, p(len/2)%n, p(len)%n]
          do i = 1,2
            do j = 2,3
              if( samp(i)>samp(j) )then
                b = samp(i)
                samp(i) = samp(j)
                samp(j) = b
              end if
            end do
          end do
          
          r = [ sortP( pack(p, p%n< samp(2)) ), &
                       pack(p, p%n==samp(2))  , &
                sortP( pack(p, p%n> samp(2)) ) ]
        end if
        end function
      end module

      PROGRAM Poll
      use strQsortMod
      use piyoMod
      IMPLICIT NONE
      integer(16) :: n
      character(10),allocatable :: s(:)
      integer(16) :: i,numP,ma
      type(pair),allocatable :: p(:)
      
      
      read*,n
      allocate( s(n),p(n) )
      do i = 1,n
        read*,s(i)
      end do
      
      s = qsort( s )
      
      p(1)%n = 1
      p(1)%s = s(1)
      numP = 1
      do i = 2,n
        if( s(i)==p(numP)%s )then
          p(numP)%n = p(numP)%n + 1
        else
          numP = numP + 1
          p(numP)%n = 1
          p(numP)%s = s(i)
        end if
      end do
      
      ma = 0
      do i = 1,numP
        ma = max( ma,p(i)%n )
      end do
      
      do i = 1,numP
        if( p(i)%n==ma )then
          print*,p(i)%s
        end if
      end do
      
   !   print*,n
   !   do i = 1,n
   !     print*,s(i)
   !   end do
      
   !   do i = 1,numP
   !     print*,p(i)
   !   end do
      
      
      END PROGRAM