object Main extends App {
  val n = scala.io.StdIn.readInt()
  var sArray = Vector.empty[String]
  (1 to n).foreach(_ =>
    sArray :+= scala.io.StdIn.readLine()
  )
  val groupS = sArray.groupBy(s => s).toVector.sortBy(_._2.length).reverse
  val maxLength = groupS(0)._2.length
  val maxS = groupS.filter(s => s._2.length == maxLength)
  maxS.sortBy(_._1).foreach { s =>
    println(s._1)
  }

}