#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define INF 1e9 using namespace std; typedef long long ll; typedef pair P; vector S; ll my_remove(int i) { ll res = S[i]; S.erase(S.begin() + i); return res; } int my_binary_search(int l, int r, ll b) { if (r - l == 1) { return r; } int c = (l + r) / 2; if (S[c] == b) { return c; } else if (S[c] > b) { return my_binary_search(l, c, b); } else { return my_binary_search(c, r, b); } } void my_insert(ll b) { int i = my_binary_search(0, int(S.size()), b); S.insert(S.begin() + i, b); } int main() { int Q, K; cin >> Q >> K; for (int i = 0; i < Q; ++i) { int a; ll b; scanf("%d", &a); if (a == 1) { scanf("%lld", &b); my_insert(b); } else { if (S.size() >= K) { ll res = my_remove(K); printf("%lld", res); } else { printf("%d", -1); } } } return 0; }