#include using namespace std; typedef long long LL; priority_queue, greater> sm; priority_queue bg; int main() { int q, k; scanf("%d%d", &q, &k); while (q--) { int id; scanf("%d", &id); if (id == 1) { LL xx; scanf("%lld", &xx); if (bg.size() < k) { bg.push(xx); } else { if (xx < bg.top()) { sm.push(bg.top()); bg.pop(); bg.push(xx); } else { sm.push(xx); } } } else { if (bg.size() < k) { puts("-1"); } else { printf("%lld\n", bg.top()); bg.pop(); if (!sm.empty()) { bg.push(sm.top()); sm.pop(); } } } } return 0; }