#include using namespace std; using ll = long long; template using vt = vector; template using vvt = vector>; template using ttt = tuple; using tii = tuple; using vi = vector; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define pb push_back #define mt make_tuple #define ALL(a) (a).begin(),(a).end() #define FST first #define SEC second #define DEB cerr<<"!"<0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;} inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;} /*Coding Space*/ template struct FT{ vector d; int top; FT(size_t n):d(n+1){top = 1; while(top < (int)d.size()) top <<= 1;} T sum(size_t i){T s{};for(++i;i>0;i-=i&-i)s+=d[i];return s;} T sum(size_t i,size_t j){return i?sum(j)-sum(i-1):sum(j);} //[l,r] void add(size_t i,T x){for(++i;i> 1; i > 0; i >>= 1){ if(ret + i < (int)d.size() && d[ret + i] < x){ x -= d[ret + i]; ret += i; } } return (ret); } }; map zip; // zipではない map un_zip; void zip_in(vector& a){ for(auto i:a) zip[i] = 1; int cnt = 1; for(auto &p:zip){ p.second = cnt++; un_zip[p.second] = p.first; } /* DEB; for(auto a: zip) SHOW(a.FST,a.SEC); for(auto a: un_zip) SHOW(a.FST,a.SEC); */ } int main(){ FT ft(200002); int q,k; cin >> q >> k; vt in; using Q = tuple; vt que; rep(i,q){ int ope; cin >> ope; if(ope == 1){ ll v; cin >> v; in.pb(v); que.pb(Q{ope,v}); }else{ que.pb(Q{ope,-1}); } } zip_in(in); for(auto QQ:que){ ll a,b; tie(a,b) = QQ; if(a == 2){ int ans = ft.lower_bound(k); cout << (ans != 200002?un_zip[ans]:-1) << endl; if(ans != 200002) ft.add(ans,-1); }else{ ft.add(zip[b],1); } } }