#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define EVAL 1 using namespace std; #define Ma_PI 3.141592653589793 #define eps 0.00000001 #define LONG_INF 3000000000000000000 #define GOLD 1.61803398874989484820458 #define MAX_MOD 1000000007 #define REP(i,n) for(long long i = 0;i < n;++i) #define seg_size 524288 #define PI 3.1415926535 using namespace std; int main(){ #define int long long iostream::sync_with_stdio(false); int query,k; cin >> query >> k; set over_k; set under_k; map over_wow,under_wow; REP(i,query){ long long a; cin >> a; if(a == 1){ cin >> a; if(i + 1LL < k){ under_k.insert(a); under_wow[a]++; }else{ auto hoge = under_k.end(); if(k == 1) goto foo; hoge--; if(*hoge <= a){ foo:; over_wow[a]++; over_k.insert(a); }else{ under_k.insert(a); under_wow[*hoge]--; if(under_wow[*hoge] == 0){ under_k.erase(*hoge); } over_k.insert(*hoge); over_wow[*hoge]++; } } }else{ if(over_k.size() != 0){ auto hoge = over_k.begin(); cout << *hoge << endl; over_wow[*hoge]--; if(over_wow[*hoge] == 0){ over_k.erase(*hoge); } }else{ cout << -1 << endl; } } } return 0; }