#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair P; typedef tuple T; long long int INF = 1e18; long long int MOD = 1e9 + 7; int main(){ int Q, K; cin >> Q >> K; priority_queue que; priority_queue, greater> que2; for(int i = 0; i < Q; i++){ int tp; cin >> tp; if(tp == 1){ long long int num; cin >> num; que.push(num); if(que.size() > K){ que2.push(que.top()); que.pop(); } }else{ if(que.size() < K){ cout << -1 << endl; }else{ cout << que.top() << endl; que.pop(); if(que2.size() > 0){ que.push(que2.top()); que2.pop(); } } } } return 0; }