#include [[nodiscard]] static inline std::vector solve(const uint_fast32_t N, const uint_fast32_t K, const uint_fast32_t Q, const std::vector& A, const std::vector>& queries) noexcept { std::priority_queue pq_under; std::priority_queue, std::greater> pq_over; for (uint_fast32_t i = 0; i < K; ++i) pq_under.push(A[i]); for (uint_fast32_t i = K; i < N; ++i) pq_over.push(A[i]); std::vector ans; ans.reserve(Q); for (const auto& [t, x] : queries) { const auto kth_element = pq_under.top(); switch (t) { case '1': if (x >= kth_element) pq_over.push(x); else pq_over.push(kth_element), pq_under.pop(), pq_under.push(x); break; case '2': if (kth_element + x <= pq_over.top()) pq_under.pop(), pq_under.push(kth_element + x); else pq_under.pop(), pq_under.push(pq_over.top()), pq_over.pop(), pq_over.push(kth_element + x); break; case '3': ans.push_back(kth_element); break; } } return ans; } static inline void output(const std::vector& ans) noexcept { for (const auto& ans : ans) std::cout << ans << '\n'; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, K, Q; std::cin >> N >> K >> Q; std::vector A(N); std::vector> queries(Q); for (auto& a : A) std::cin >> a; for (auto& [t, x] : queries) { std::cin >> t; if (t != '3') std::cin >> x; } std::sort(A.begin(), A.end()); output(solve(N, K, Q, A, queries)); return 0; }