#include "bits/stdc++.h" #include #include #include using namespace std; using namespace __gnu_pbds; using Node = pair; tree, rb_tree_tag, tree_order_statistics_node_update> S; int main() { int Q, K, cnt = 0; scanf("%d%d", &Q, &K); for(int i = 0; i < Q; i++) { int q; scanf("%d", &q); if (q == 1) { long long int v; scanf("%lld", &v); S.insert(make_pair(v, cnt++)); } else { if (S.size() < K) { puts("-1"); } else { auto it = S.find_by_order(K - 1); printf("%lld\n", *it); S.erase(it); } } } return 0; }