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]); StringBuilder sb = new StringBuilder(); ArrayList list = new ArrayList<>(); list.add(0L); list.add(Long.MAX_VALUE); for (int i = 0; i < q; i++) { String s = br.readLine(); if (s.charAt(0) == '1') { long x = Long.parseLong(s.split(" ", 2)[1]); int left = 0; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; if (list.get(m) < x) { left = m; } else { right = m; } } list.add(right, x); } else { if (list.size() < k + 2) { sb.append(-1); } else { sb.append(list.remove(k)); } sb.append("\n"); } } System.out.print(sb); } }