while true
    n, q = gets.chomp.split.map(&:to_i)
    break if [n, q] == [0, 0]
    arr = Array.new(100, 0)
    n.times{
        line = gets.chomp.split.map(&:to_i)
        line[1..-1].each{|day| arr[day] += 1}
    }
    date, x = 0, 0
    for i in 1..99
        if arr[i] > x && arr[i] >= q
            date = i
            x = arr[i]
        end
    end
    puts date
end
