#include #include using namespace __gnu_pbds; using namespace std; using int64 = long long; tree< pair< int64, int >, null_type, less< pair< int64, int > >, rb_tree_tag, tree_order_statistics_node_update > ts; int main() { int Q, K; scanf("%d %d", &Q, &K); --K; int ptr = 0; while(Q--) { int t; scanf("%d", &t); if(t == 1) { int64 x; scanf("%lld", &x); ts.insert(make_pair(x, ptr++)); } else { if((int) ts.size() - 1 >= K) { auto p = ts.find_by_order(K); printf("%lld\n", p->first); ts.erase(p); } else { puts("-1"); } } } }