import kotlin.comparisons.compareBy
import kotlin.comparisons.thenBy

fun main(args: Array<String>) {

    val map = mutableMapOf<String, Int>()
    var max = 0
    repeat(readLine()!!.toInt()) {
        readLine()!!.let {
            val value = map.getOrElse(it, { 0 }) + 1
            map.put(it, value)
            max = Math.max(value, max)

        }
    }

    map.toList().filter { it.second == max }
        .sortedWith(compareBy<Pair<String, Int>> { it.second }.thenBy { it.first })
        .forEach {
            println(it.first)
        }
}

