import sys input = lambda: sys.stdin.readline().rstrip() class FenwickTree: def __init__(self, n: int): "Build a new fenwick tree. / O(N)" assert 0 <= n <= 10**8 self._size = n self._tree = [0] * (n+1) self._depth = n.bit_length() def _sum(self, i): "Return sum([0, i)) of a. / O(logN)" i += 1 # 1-indexed ret = 0 while i > 0: ret += self._tree[i] i -= i & -i return ret def sum(self, l: int, r: int): "Return sum([l, r)] of a. / O(logN)" assert 0 <= l <= r <= self._size return self._sum(r-1) - self._sum(l-1) def add(self, p: int, x) -> None: "Add x to a[p]. / O(logN)" p += 1 # 1-indexed. assert 1 <= p <= self._size while p <= self._size: self._tree[p] += x p += p & -p return def lower_bound(self, w): "Return 累積和がx以上になる最小のindexと、その直前までの累積和 / O(logN)" ''' FenwickTreeを集合として管理 add(a, 1) -> 集合にaを追加 add(a,-1) -> 集合からaを削除 sum(a) -> aが何番目に小さいかを返す lower_bound(w) -> w番目に小さい要素を返す ''' acc, pos = 0, 0 for i in range(self._depth, -1, -1): k = pos + (1 << i) if k <= self._size and acc + self._tree[k] < w: acc += self._tree[k] pos += 1 << i return pos+1, acc ################## Q, K = map(int, input().split()) qu = [list(map(int, input().split())) for _ in range(Q)] A = [] for q in qu: if q[0] == 1: v = q[1] A.append(v) dictonum = {x:i for i,x in enumerate(sorted(list(set(A))))} dictox = {i:x for i,x in enumerate(sorted(list(set(A))))} n = len(A) fw = FenwickTree(n) ans = [] for q in qu: if q[0] == 1: v = dictonum[q[1]] fw.add(v, 1) else: if fw.sum(0, n) < K: ans.append(-1) else: w = fw.lower_bound(K)[0] ans.append(dictox[w-1]) fw.add(w-1, -1) print('\n'.join(map(str, ans)))