import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int q = Integer.parseInt(first[0]); int k = Integer.parseInt(first[1]); LinkedList list = new LinkedList<>(); list.add(Long.MIN_VALUE); list.add(Long.MAX_VALUE); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { String[] line = br.readLine().split(" "); int type = Integer.parseInt(line[0]); if (type == 1) { long x = Long.parseLong(line[1]); int left = 0; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; if (list.get(m) > x) { right = m; } else { left = m; } } list.add(right, x); } else { if (list.size() - 2 < k) { sb.append(-1); } else { sb.append(list.get(k)); list.remove(k); } sb.append("\n"); } } System.out.print(sb); } }