k, s = gets.split[1].to_i, [] while (input = gets) if v = input.split.map(&:to_i)[1] then s.push(v) s.sort! else puts s.size >= k ? s.delete_at(k - 1) : -1 end end