import java.util.*; public class Main { static final long MAX = (long)Math.sqrt(Long.MAX_VALUE); public static void main (String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); int k = sc.nextInt(); StringBuilder sb = new StringBuilder(); ArrayList list = new ArrayList<>(); list.add(0L); list.add(Long.MAX_VALUE); for (int i = 0; i < q; i++) { int type = sc.nextInt(); if (type == 1) { long x = sc.nextLong(); 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); } }