loop do
    n, q = gets.split.map(&:to_i)
    break if n == 0 && q == 0
    date = Array.new(101, 0)
    n.times do
        d = gets.split.map(&:to_i)
        for i in 1...d.size
            date[d[i]] += 1
        end
    end
    max = maxi = 0
    date.each_with_index do |d, i|
        next if d < q
        if d > max
            max = d
            maxi = i
        end
    end
    puts maxi
end