class Set(): #BinaryIndexedTree def __init__(self, valuelist): self.n = len(valuelist) self.value = sorted(valuelist) self.comp = {v : k for k, v in enumerate(self.value, 1)} self.bit = BinaryIndexedTree(self.n) def insert(self, x, k=1): self.bit.add(self.comp[x], k) def delete(self, x, k=1): self.bit.add(self.comp[x], -k) def count(self, x): return self.bit.get(self.comp[x]) def get(self, k): return self.value[self.bit.bisect_left(k)-1] class BinaryIndexedTree(): #1-indexed def __init__(self, n): self.n = n self.tree = [0 for _ in range(n + 1)] def sum(self, index): res = 0 while index: res += self.tree[index] index -= index & -index return res def get(self, index): return self.sum(index) - self.sum(index - 1) def add(self, index, x): while index <= self.n: self.tree[index] += x index += index & -index def bisect_left(self, x): if x <= 0: return 0 res, tmp = 0, 2**((self.n).bit_length() - 1) while tmp: if res + tmp <= self.n and self.tree[res + tmp] < x: x -= self.tree[res + tmp] res += tmp tmp >>= 1 return res + 1 import sys input = sys.stdin.readline INF = 10**18 + 1 Q, K = map(int, input().split()) query = [] value = [INF] for _ in range(Q): q = tuple(map(int, input().split())) if q[0] == 1: value.append(q[1]) query.append(q) S = Set(set(value)) S.insert(INF) for q in query: if q[0] == 1: S.insert(q[1]) else: v = S.get(K) if v == INF: print(-1) else: print(v) S.delete(v)