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::()) .enumerate() .map(|v| (v.1, v.0)); let mut s = BTreeSet::new(); while let Some(q) = query.next() { match q.0 { 1 => { let val = query.next().unwrap(); s.insert(val); } 2 => { if s.len() < k as usize { println!("-1"); } else { let val = s.iter().skip(k as usize - 1).next().unwrap().clone(); println!("{}", val.0); s.remove(&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() }