import sys input = sys.stdin.readline class BIT: def __init__(self, n): self.n = n self.data = [0] * (n + 1) def ope(self, x, y): return x + y def update(self, i, v): while i <= self.n: self.data[i] = self.ope(self.data[i], v) i += i & -i def query(self, i): ret = 0 while 0 < i: ret = self.ope(self.data[i], ret) i &= i - 1 return ret def lowerBound(self, w): if w <= 0: return 0 x, k = 0, 2**self.n.bit_length() while k: if x+k <= self.n and self.data[x+k] < w: w -= self.data[x+k] x += k k >>= 1 return x + 1 def main(): q, k = map(int, input().split()) vs = set() query = [] for i in range(q): s = input() if len(s) != 2: _, v = map(int, s.split()) vs.add(v) query.append(v) else: query.append(-1) # 座圧, 1-indexed d = {} dd = {} for i, j in enumerate(sorted(list(vs))): d[j] = i+1 dd[i+1] = j # BIT n = len(d) B = BIT(n) for q in query: if q >= 0: p = d[q] B.update(p, 1) else: if B.query(n) >= k: a = B.lowerBound(k) print(dd[a]) B.update(a, -1) else: print(-1) if __name__ == "__main__": main()