Q, K = map(int, input().split()) s = [] for q in range(Q): line = input().strip() if line[0] == '1': _, val = map(int, line.split()) s.append(val) if line[0] == '2': if len(s) < K: print(-1) continue else: s = sorted(s) val = s.pop(K-1) print(val)