#
# 1124:
#

MAXD = 100

loop do
    n, q = gets.split.map(&:to_i)
    break if (n | q) == 0
    
    votes = MAXD.times.map{0}
    
    n.times do
        ns = gets.split.map(&:to_i)
        m = ns.shft
        
        for i in (0...m)
            votes[ns[i]] += 1
        end
    end
    
    maxv = 0
    mind = 0
    
    for d in (0...MAXD)
        v = votes[i]
        if maxv < v 
            maxv = v 
            mind = d 
        end
    end
    
    puts (maxv < q ? 0 : mind)
end