import sys r = sys.stdin Q,K = map(int,r.readline().split()) l = [] s = set() for _ in range(Q): a = list(map(int,r.readline().split())) if a[0] == 1: l.append(a[1]) s.add(a[1]) else: l.append(-2) D = {v:i+1 for i,v in enumerate(sorted(s))} rD = {i+1:v for i,v in enumerate(sorted(s))} n = len(D) bit = [0] * (n +1) def add(i,x): while i <= n: bit[i] += x i += i &-i def lb(w): if w <= 0:return 0 k = 1 while k < n: k <<= 1 k >>= 1 x = 0 while k > 0: if x + k <= n and bit[x+k] < w: w -= bit[x+k] x += k k >>= 1 return x + 1 for v in l: if v != -2: add(D[v],1) else: x = lb(K) if x == n + 1: print(-1) else: print(rD[x]) add(x,-1)