
fun main(args:Array<String>):Unit {
    var (n, q) = readLine()!!.split(' ').map(String::toInt)
    while (n != 0 || q != 0){
        val dateSuspect = Array(100){0}
        repeat(n){
            readLine()!!.split(' ').map(String::toInt).drop(1).forEach { dateSuspect[it]++ }
        }
        val date = dateSuspect.withIndex().filter{it.value >= q}.maxBy{it.value}
        println(date?.index ?: 0)
        val (nn, nq) = readLine()!!.split(' ').map(String::toInt)
        n = nn
        q = nq
    }
}


