#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; int main(void) { cin.tie(0); ios::sync_with_stdio(0); ll q, k; cin >> q >> k; vector t(q), v(q, -1); rep(i, 0, q) { cin >> t[i]; if(t[i] == 1) cin >> v[i]; } vector comp = v; sort(comp.begin(), comp.end()); comp.erase(unique(comp.begin(), comp.end()), comp.end()); vector val(q); map mp; rep(i, 0, q) { val[i] = lower_bound(comp.begin(), comp.end(), v[i]) - comp.begin(); mp[val[i]] = v[i]; } fenwick_tree fw(q + 1); rep(i, 0, q) { if(t[i] == 1) { fw.add(val[i], 1); } else { ll left = -1, right = q + 1; while(right - left > 1) { ll mid = (left + right) / 2; if(fw.sum(0, mid) >= k) { right = mid; } else { left = mid; } } if(right == q + 1) { cout << -1 << '\n'; } else { cout << mp[right - 1] << '\n'; fw.add(right - 1, -1); } } } }