loop do
  n,q = gets.split.map(&:to_i)
  break if n==0

  conv = Array.new(100,0)
  n.times do
    _, *d = gets.split.map(&:to_i)

    next if d.nil?
    d.each do |i|
      conv[i] += 1
    end
  end

  best = conv.each_with_index.sort_by{|num,i| [-num,i]}[0]
  if best[0] < q
    puts 0
  else
    puts best[1]
  end
end