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