#include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long int lint; using namespace std; #define INF 1000000000000000005 int main() { lint q,k; std::cin >> q >> k; std::vector query; lint index = 0; for(lint i = 0; i < q; i++){ lint temp = 0; std::cin >> temp; if(temp == 1){ lint v = 0; std::cin >> v; query.push_back(v); index++; } else { if(index >= k){ std::sort(query.begin(),query.end()); std::cout << query[k - 1] << std::endl; query[k - 1] = INF; index--; } else { std::cout << -1 << std::endl; } } } return 0; }