#BITを用いた実装 class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self,w): ''' a1+a2+...+ax>=wとなるような最小のxを求める https://algo-logic.info/binary-indexed-tree/ ''' if w<=0: return 0 else: x = 0 r = 1 while r < self.size: r = r<<1 lenth = r S = 0 while lenth > 0: if lenth + x < self.size and self.tree[x+lenth] < w: w -= self.tree[x+lenth] x += lenth lenth = lenth>>1 return x+1 Q,K = map(int,input().split()) query = [list(map(int,input().split())) for _ in range(Q)] V = set() for q in query: if q[0] == 1: V.add(q[1]) V = sorted(V) d = {v:i for i,v in enumerate(V)} bit = Bit(len(V)) for q in query: if q[0] == 1: bit.add(d[q[1]]+1,1) else: if bit.sum(len(V)) < K: print(-1) else: x = bit.lower_bound(K) print(V[x-1]) bit.add(x,-1)