object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var n, q = sc.nextInt
    while(n != 0 || q != 0) {
      val cand = (for(_ <- 1 to n) yield {
        for(_ <- 1 to sc.nextInt) yield sc.nextInt }).flatten
      println(((1 to 100)
        .toList.map(x => (cand.count(_ == x), x))
        .filter(_._1 >= q)
        .sortWith((a, b) =>
          if(a._1 == b._1) a._2 < b._2 else a._1 > b._1) :+ (0, 0)).head._2)
      n = sc.nextInt
      q = sc.nextInt
    }
  }
}