
fun main(args:Array<String>):Unit {
    while (true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val charactors = Array(n) {
            val arg = readLine()!!.trim().split(' ')
            Charactor(arg.first(), arg.drop(2).map(String::toInt))
        }
        val times = Array(31) { n + 1 }
        charactors.forEach { it.appearTimes().forEach { times[it]-- } }
        val score = charactors.map {
            Pair(it.name, it.appearTimes().sumBy { times[it] })
        }.sortedWith(compareBy(Pair<String, Int>::second, Pair<String, Int>::first)).first()
        println("${score.second} ${score.first}")
    }
}
data class Charactor(val name:String, private val mTimes:Iterable<Int>){
    fun appearTimes():Iterable<Int> = mTimes
}
