class BIT: #0-indexed __slots__ = ["size", "tree","depth","n0"] def __init__(self, n): self.size = n self.tree = [0]*(n+1) self.depth = n.bit_length() self.n0 = 1< 0: s += self.tree[i] i -= i & -i return s def range_sum(self,l,r): #a_l + ... + a_r 閉区間 return self.get_sum(r) - self.get_sum(l-1) def range_sum_larger(self,l): #a_l + ... (端まで) return self.get_sum(self.size-1) - (self.get_sum(l-1) if l else 0) def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x i += i & -i def bisect_left(self,w): #和が w 以上になる最小の index #w が存在しない場合 self.size を返す if w <= 0: return 0 x,k = 0,self.n0 for _ in range(self.depth): k >>= 1 if x+k <= self.size and self.tree[x+k] < w: w -= self.tree[x+k] x += k return x Q,K = map(int,input().split()) query = [list(map(int,input().split())) for _ in range(Q)] nums = set() for a in query: if a[0]==1: nums.add(a[1]) bit = BIT(len(nums)) zaatu = {ai:i for i, ai in enumerate(sorted(nums))} nums = sorted(nums) c = 0 for a in query: if a[0]==1: bit.add(zaatu[a[1]],1) c += 1 else: if c < K: print(-1) else: idx = bit.bisect_left(K) print(nums[idx]) bit.add(idx,-1) c -= 1