import heapq q, k = map(int, input().split()) k_elements = [] #max tmp = [] #min for _ in range(q): que = list(map(int, input().split())) if que[0] == 1: v = que[1] heapq.heappush(k_elements, -v) if len(k_elements) > k: maxv = -heapq.heappop(k_elements) heapq.heappush(tmp, maxv) else: if len(k_elements) != k: print(-1) else: maxv = -heapq.heappop(k_elements) print(maxv) if tmp: minv = heapq.heappop(tmp) heapq.heappush(k_elements, -minv)