import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) class SegmentTree(object): #N:処理する区間の長さ def __init__(self, N): self.N = N self.N0 = 2 ** (N - 1).bit_length() self.initVal = 0 self.data = [self.initVal] * (2 * self.N0) # 区間クエリの種類 def calc(self, a, b): return a + b # k番目の値を取得 def pointQuery(self, k): return self.data[k + self.N0 - 1] # k番目の値にxを加算 def add(self, k, x): k += self.N0 - 1 self.data[k] += x while k > 0: k = (k - 1) // 2 self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2]) #区間[l, r]の演算値 def query(self, l, r): L = l + self.N0; R = r + self.N0 + 1 m = self.initVal while L < R: if R & 1: R -= 1 m = self.calc(m, self.data[R - 1]) if L & 1: m = self.calc(m, self.data[L - 1]) L += 1 L >>= 1; R >>= 1 return m def Binary_Search(Seg, K): #初期化 left = 0 right = 2 * (10 ** 5) itr = INF #二分探索 while left <= right: mid = (left + right) // 2 if Seg.query(0, mid) < K: left = mid + 1 else: itr = min(itr, mid) right = mid - 1 return itr #処理内容 def main(): Q, K = getlist() val = 0 Seg = SegmentTree(2 * (10 ** 5) + 1) for i in range(Q): q = getlist() if q[0] == 1: val += 1 x = q[1] Seg.add(x, 1) else: if val < K: print(-1) else: itr = Binary_Search(Seg, K) print(itr) Seg.add(itr, -1) val -= 1 if __name__ == '__main__': main()