#include using namespace std; typedef long long ll; int q, k; priority_queue, greater> minq; priority_queue maxq; void f1() { ll v; scanf("%lld", &v); if (maxq.size() < k) { maxq.push(v); } else { if (maxq.top() > v) { int tmp = maxq.top(); maxq.pop(); maxq.push(v); v = tmp; } minq.push(v); } } void f2() { if (maxq.size() < k) { puts("-1"); } else { cout << maxq.top() << endl; maxq.pop(); if (minq.size() > 0) { maxq.push(minq.top()); minq.pop(); } } } int main() { scanf("%d %d", &q, &k); while (q--) { int query; scanf("%d", &query); if (query == 1) f1(); else f2(); } return 0; }