#include #include using namespace __gnu_pbds; #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using namespace __gnu_pbds; #ifdef Himesaka #include #define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif // clang-format off /* #language C++ GCC */ struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << setprecision(13); } }init; constexpr char nl = '\n'; #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (lint i = lint(a); i < lint(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define all(a) (a).begin(), (a).end() #define rall(x) (x).rbegin(), (x).rend() #define SUM(v) accumulate(all(v), (ll)0) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define pb push_back #define is insert #define fi first #define sc second #define ifnot(x) if(!(x)) #define al(i, v) for (auto &i : v) #define alm(ii,mm) for(auto ii=mm.begin();ii!=mm.end();ii++) #define yes() cout << "Yes" << '\n' #define no() cout << "No" << '\n' #define yn(n) cout << ((n) ? "Yes" : "No") << '\n' #define co() cout << nl; #define len(c) (lint)(c).size() #define inr(l, x, r) (l <= x && x <= r) #define popcount(x) __builtin_popcountll(x) typedef string str;typedef long long ll;typedef long long lint;typedef long double ld;typedef pairpll;typedef pairpii;typedef vector vi;typedef vector vb;typedef vector vd;typedef vector vc;typedef vector vl;typedef vector vs;typedef vector> vvi;typedef vector> vvl;typedef vector> vvc;typedef vector> vvb;typedef vector vpl;templatevoid snx(T &a){cin>>a;}void inz() {}template void inz(Head &head, Tail &...tail){snx(head);inz(tail...);} template using tree_set = tree, rb_tree_tag, tree_order_statistics_node_update>; #define scan(x) al(i, x) cin >> i #define int_(...) int __VA_ARGS__;inz(__VA_ARGS__) #define lint_(...) lint __VA_ARGS__;inz(__VA_ARGS__) #define ld_(...) ld __VA_ARGS__;inz(__VA_ARGS__) #define str_(...) string __VA_ARGS__;inz(__VA_ARGS__) #define char_(...) char __VA_ARGS__;inz(__VA_ARGS__) #define vi_(ne,sz) vi ne(sz);scan(ne); #define vl_(ne,sz) vl ne(sz);scan(ne); #define vb_(ne,sz) vb ne(sz);scan(ne); #define vd_(ne,sz) vd ne(sz);scan(ne); #define vc_(ne,sz) vc ne(sz);scan(ne); #define vs_(ne,sz) vs ne(sz);scan(ne); #define snn(h,w,a) rep(i,h)rep(j,w) cin >> a[i][j]; #define vvi_(ne,h,w) vvi ne(h,vi(w,0));snn(h,w,ne) #define vvl_(ne,h,w) vvl ne(h,vl(w,0));snn(h,w,ne) #define vvc_(ne,h,w) vvc ne(h,vc(w,0));snn(h,w,ne) #define vvb_(ne,h,w) vvb ne(h,vb(w,0));snn(h,w,ne) #define vpl_(ne,m) vpl ne(m); rep(i,m)cin>>ne[i].fi>>ne[i].sc; ostream &operator<<(ostream &os, const vpl &v) {for (auto &[e1, e2] : v){os << e1 << ' ' << e2 << endl;}return os;} template ostream &operator<<(ostream &os, const vector &v){for (auto &e : v)os << e << ' ';return os;} template ostream &operator<<(ostream &os, const set &v){for (auto &e : v)os << e << ' ';return os;} template ostream &operator<<(ostream &os, const multiset &v){for (auto &e : v)os << e << ' ';return os;} template vector &operator++(vector &v) {al(e,v) e++;return v;} template vector operator++(vector &v, signed) {auto res = v;al(e,v) e++;return res;} template vector &operator--(vector &v) {al(e,v) e--;return v;} template vector operator--(vector &v, signed) {auto res = v;al(e,v) e--;return res;} vector &operator--(vector &v) {al(e,v) e.fi--,e.sc--;return v;} vector operator--(vector &v, signed) {auto res = v;al(e,v)e.fi--,e.sc--;return res;} template<> struct std::vector: std::basic_string {using std::basic_string::basic_string, std::basic_string::operator =;explicit vector(size_t n): vector(n, false) {}}; template set operator|(set a, set b){set ret;set_union(all(a), all(b), inserter(ret, ret.begin()));return ret;} template multiset operator|(multiset a, multiset b){multiset ret;set_union(all(a), all(b), inserter(ret, ret.begin()));return ret;} template set operator&(set a, set b){set ret;set_intersection(all(a), all(b), inserter(ret, ret.begin()));return ret;} template multiset operator&(multiset a, multiset b){multiset ret;set_intersection(all(a), all(b), inserter(ret, ret.begin()));return ret;} template set operator-(set a, set b){set ret;set_symmetric_difference(all(a), all(b), inserter(ret, ret.begin()));return ret;} template multiset operator-(multiset a, multiset b){multiset ret;set_symmetric_difference(all(a), all(b), inserter(ret, ret.begin()));return ret;} ostream &operator<<(ostream &os, const vvc &v) {for (auto &e : v){for (auto &c : e)os << c;os << endl;}return os;} ostream &operator<<(ostream &os, const vvl &v) {for (auto &e : v){for (auto &c : e)os << c << ' ';os << endl;}return os;} template void input(T &...a){(cin >> ... >> a);} void out(){cout << '\n';}template void out(const T &a, const Ts &...b){cout << a; (cout << ... << (cout << ' ', b));cout << '\n';} void print(){cout << '\n';}template void print(const T &a, const Ts &...b){cout << a; (cout << ... << (cout << ' ', b));cout << '\n';} void exit_no(void){cout<<"No"< void exit_(T x){cout< void exit_(const T& a, const Ts&... b){cout << a;(cout << ... << (cout << ' ', b));cout << '\n';exit(0);} template bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; } template bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; } template void sort(T &v) {sort(all(v));} template void rsort(T &v) {sort(rall(v));} template void reverse(T &v) {reverse(all(v));} template vector ret_ex(vector v){T n = len(v);vector e(n + 1, 0);rep(i, 1, n + 1) e[i] = e[i - 1] + v[i - 1];return e;} template map count_v(vector v){mapres;al(x,v)res[x]++;return res;} mapcount_s(str s) {mapres;al(x,s)res[x]++;return res;} template bool is_out(T y,T x,U h,U w){return (y<0||y>=h||x<0||x>=w);} const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string abc = "abcdefghijklmnopqrstuvwxyz"; const lint dx[8] = {1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1}; const int inf = INT_MAX/2; const lint infl = 1LL<<60; const ld PI = acos(-1.0); template vector> r_rot(vector> g) {lint h = g.size(), w = g[0].size();vector> res(h, vector(w));rep(i, h) rep(j, w) res[j][w - 1 - i] = g[i][j];return res;} template vector> l_rot(vector> g) {lint h = g.size(), w = g[0].size();vector> res(h, vector(w));rep(i, h) rep(j, w) res[w - 1 - j][i] = g[i][j];return res;} set normalize_grid(vvc g){set se;rep(i, g.size()) rep(j, len(g[i])){if (g[i][j] == '#')se.is({i, j});}lint miy{infl}, mix{infl};al(x, se){chmin(miy, x.fi);chmin(mix, x.sc);}set ans;al(x, se)ans.is({x.fi - miy, x.sc - mix});return ans;} multiset m_normalize_grid(vvc g){multiset se;rep(i, g.size()) rep(j, len(g[i])){if (g[i][j] == '#')se.is({i, j});}lint miy{infl}, mix{infl};al(x, se){chmin(miy, x.fi);chmin(mix, x.sc);}multiset ans;al(x, se)ans.is({x.fi - miy, x.sc - mix});return ans;} set normalize_set(set se){lint miy{infl}, mix{infl};al(x, se){chmin(miy, x.fi);chmin(mix, x.sc);}set ans;al(x, se)ans.is({x.fi - miy, x.sc - mix});return ans;} multiset m_normalize_set(multiset se){lint miy{infl}, mix{infl};al(x, se){chmin(miy, x.fi);chmin(mix, x.sc);}multiset ans;al(x, se)ans.is({x.fi - miy, x.sc - mix});return ans;} bool NE(ld a, ld b){return abs(a - b) < DBL_EPSILON;} template T pow_mod(T A, T N, T M) {T res = 1 % M;A %= M;while (N) {if (N & 1) res = (res * A) % M;A = (A * A) % M;N >>= 1;}return res;} bool is_prime(ll N) {if (N <= 1)return false;if (N == 2 || N == 3)return true;if (N % 2 == 0)return false;vl A = {2, 325, 9375, 28178, 450775,9780504, 1795265022};ll s = 0, d = N - 1;while (d % 2 == 0){++s;d >>= 1;}for (auto a : A){if (a % N == 0)return true;ll t, x = pow_mod<__int128_t>(a, d, N);if (x != 1){for (t = 0; t < s; ++t){if (x == N - 1)break;x = __int128_t(x) * x % N;}if (t == s)return false;}}return true;} ll pollard(ll N) {if (N % 2 == 0)return 2;if (is_prime(N))return N;auto f = [&](ll x) -> ll {return (__int128_t(x) * x + 1) % N;};ll step = 0;while (true){++step;ll x = step, y = f(x);while (true){ll p = gcd(y - x + N, N);if (p == 0 || p == N)break;if (p != 1)return p;x = f(x);y = f(f(y));}}} vl prime_factorize(ll N){if (N == 1)return {};ll p = pollard(N);if (p == N)return {p};vl left = prime_factorize(p);vl right = prime_factorize(N / p);left.is(left.end(), right.begin(), right.end());sort(all(left));return left;} vpl prime_fact(lint n) {vl pr = prime_factorize(n);vpl ans{};rep(i, len(pr)){lint cnt{1}, num = pr[i];while (i + 1 < len(pr) && pr[i + 1] == num)cnt++, i++;ans.pb({num, cnt});}return ans;} template T d_pow(T x, T n) {T ret = 1;while (n > 0){if (n & 1)ret *= x;x *= x;n >>= 1;}return ret;} template T digitnum(T x, T b = 10){T ret = 0; for(; x; x /= b) ret++; return ret;} template T digitsum(T x, T b = 10){T ret = 0; for(; x; x /= b) ret += x % b; return ret;} template str to_baseB(T x, U b) {str r{};while (x){lint n = x % b;r = (char)((n <= 9) ? ('0' + n) : ('A' + n - 10)) + r;x /= b;}return r;} lint to_base10(str x, lint b = 10) {lint r{}, base = 1;for (lint i = len(x) - 1; i >= 0; --i){lint n = ('0' <= x[i] && x[i] <= '9') ? (x[i] - '0') : (x[i] - 'A' + 10);r += base * n;base *= b;}return r;} template T nPr(T n, T r) {T i, result = 1;rep(i, r) { result *= (T)(n - i); }return result;} template T nCr(T n, T r){T i,result = 1;rep(i, min(r, n - r)){result *= (T)(n - i);result /= (T)(i + 1);}return result;} template vector div(T n){vector ret;for (T i = 1; i * i <= n; i++)if (!(n % i)){ ret.pb(i);if (i * i != n) ret.pb(n / i);}sort(all(ret)); return ret;} ll arith(ll x) { return x * (x + 1) / 2; } ll arith2(ll a, ll d, ll n){return n * (2 * a + (n - 1) * d) / 2; } vl sieve(lint n) {vl res;vector mem(n, 0);for (int i = 2; i < n; i++){if (mem[i]){continue;}res.push_back(i);for (int j = i; j < n; j += i){mem[j] = 1;}}return res;} lint ret_dist(lint y1,lint x1,lint y2,lint x2){return powl(y2 - y1,2) + powl(x2 - x1,2);} lint mgr(lint ok, lint ng, auto is_ok) {while (abs(ok - ng) > 1){lint mid = (ok + ng) / 2;is_ok(mid) ? ok = mid : ng = mid;};return ok;} ld mgr_double(ld ok, ld ng, auto is_ok) {rep(_, 60){ld mid = (ok + ng) / 2;is_ok(mid) ? ok = mid : ng = mid;}return ok;} // clang-format on template class Comp { vector vals; vector comp; public: Comp(const vector &data) : vals(data), comp(data.size()) { sort(vals.begin(), vals.end()); vals.erase(unique(vals.begin(), vals.end()), vals.end()); for (int i = 0; i < comp.size(); i++) comp[i] = lower_bound(vals.begin(), vals.end(), data[i]) - vals.begin(); } int get_index(T value) { auto lb = lower_bound(vals.begin(), vals.end(), value); assert(lb != vals.end() && *lb == value); return (int)(lb - vals.begin()); } T get_value(size_t index) { return vals.at(index); } int operator[](size_t index) const { return comp.at(index); } vector get_compressed_vector() const { return comp; } int size() const { return vals.size(); } }; #include using namespace __gnu_pbds; template using tree_set = tree, rb_tree_tag, tree_order_statistics_node_update>; int main() { tree_set se; lint_(q, k); lint cnt{}; for (; q--;) { lint_(t); if (t == 1) { lint_(x); se.is({x, cnt++}); } if (t == 2) { if (se.size() < k) out(-1); else { auto it = se.find_by_order(k - 1); out(it->fi); se.erase(it); } } } }