use std::{ collections::{BTreeSet, HashMap, HashSet, VecDeque}, fmt::Debug, io::stdin, str::FromStr, }; use proconio::marker::Chars; fn main() { // proconio::input! { // q: usize, // k: usize, // } let x = read::(); let (q, k) = (x[0], x[1]); let mut query = (0..q).flat_map(|_| read::()); let mut s = Vec::new(); while let Some(q) = query.next() { match q { 1 => { let val = query.next().unwrap(); let p = s.partition_point(|&a| a < val); s.insert(p, val); } 2 => { if s.len() < k as usize { println!("-1"); } else { let val = s.remove(k as usize - 1); println!("{val}"); } } _ => unreachable!(), } } } fn read() -> Vec where T: FromStr, ::Err: Debug, { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); s.split(' ').map(|v| v.trim().parse().expect(v)).collect() }