k, s = gets.split[1].to_i, [] while (input = gets) print (v = input.split.map(&:to_i)[1]) ? (s.push(v) ; nil) : "#{s.size >= k ? (s.sort! ; s.delete_at(k - 1)) : -1}\n" end