#include #include using namespace std; using namespace atcoder; using ll = long long; using P = pair; using mint = modint998244353; #include #include #include using namespace __gnu_pbds; // using Tree = tree,rb_tree_tag,tree_order_statistics_node_update>; // set using Tree = tree, rb_tree_tag, tree_order_statistics_node_update>; // multiset #define rep(i, a, b) for(ll i = a; i < b; i++) #define rrep(i, a, b) for(ll i = a; i >= b; i--) constexpr ll inf = 4e18; int main(void) { cin.tie(0); ios::sync_with_stdio(0); ll q, k; cin >> q >> k; Tree st; while(q--) { ll t; cin >> t; if(t == 1) { ll v; cin >> v; st.insert(v); } else { auto itr = st.find_by_order(k - 1); if(itr == st.end()) { cout << -1 << '\n'; } else { cout << *itr << '\n'; st.erase(itr); } } } }