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