q, k = gets.split.map(&:to_i) s = [] q.times{ if v = gets.split.map(&:to_i)[1] then if s == [] || v >= s[-1] then s.push(v) elsif v <= s[0] then s.unshift(v) else for i in 0...s.size do if v > s[i] then s.insert(i, v) break end end end else puts s.size >= k ? s.delete_at(k - 1) : -1 end }