#include #include using namespace std; using namespace atcoder; using ll = long long; using P = pair; using mint = modint998244353; #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; #include #include #include using namespace __gnu_pbds; using Tree = tree, rb_tree_tag, tree_order_statistics_node_update>; // set int main(void) { cin.tie(0); ios::sync_with_stdio(0); int Q, K; cin >> Q >> K; Tree tree; map mp; while(Q--) { int t; cin >> t; if(t == 1) { ll v; cin >> v; mp[v]++; tree.insert(P(v, mp[v])); } else { if((int)tree.size() < K) { cout << -1 << '\n'; } else { auto itr = tree.find_by_order(K - 1); cout << (*itr).first << '\n'; tree.erase(itr); } } } }