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