import java.util.*; public class Main { static int N; static int[] dat; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); int k = sc.nextInt(); HashSet set = new HashSet(); ArrayList list = new ArrayList(); long[][] que = new long[q][2]; for(int i = 0; i < q; i++) { int s1 = sc.nextInt(); if(s1 == 1) { long s2 = sc.nextInt(); que[i][0] = 1; que[i][1] = s2; set.add(s2); } else { que[i][0] = 2; } } for(Iterator i = set.iterator(); i.hasNext();) { list.add(i.next()); } Collections.sort(list); long[] ret = new long[list.size()]; HashMap map = new HashMap(); for(int i = 0; i < list.size(); i++) { long r = list.get(i); map.put(r, i); ret[i] = r; } init(list.size()); for(int i = 0; i < q; i++) { if(que[i][0] == 1) { update(map.get(que[i][1]), 1); } else { int l = 0; int r = list.size(); int ans = 0; if(query(0, N, 0, 0, N) >= k) { while(l < r) { int med = (l + r) / 2; int sum = query(0, med + 1, 0, 0, N); if(sum == k) { ans = med; r = med; } else if(sum > k) { ans = med; r = med; } else { l = med + 1; } } update(ans, -1); System.out.println(ret[ans]); } else { System.out.println(-1); } } } } public static void init(int n_) { int n = 1; while(n < n_) { n *= 2; } N = n; dat = new int[2 * N - 1]; } public static void update(int k, int x) { int a = k + N - 1; dat[a] += x; while(a > 0) { a = (a - 1) / 2; dat[a] = dat[2 * a + 1] + dat[2 * a + 2]; } } public static int query(int a, int b, int k, int l, int r) { if((r <= a) || (l >= b)) return 0; if((a <= l) && (r <= b)) { return dat[k]; } else { int vl = query(a, b, 2 * k + 1, l, (l + r) / 2); int vr = query(a, b, 2 * k + 2, (l + r) / 2, r); return vl + vr; } } }