{"problem":{"name":"Sorting Queries","description":{"content":"We have an empty sequence $A$. You will be given $Q$ queries, which should be processed in the order they are given. Each query is of one of the three kinds below: *   `1 x` : Append $x$ to the end o","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc217_e"},"statements":[{"statement_type":"Markdown","content":"We have an empty sequence $A$. You will be given $Q$ queries, which should be processed in the order they are given. Each query is of one of the three kinds below:\n\n*   `1 x` : Append $x$ to the end of $A$.\n*   `2` : Print the element at the beginning of $A$. Then, delete that element. It is guaranteed that $A$ will not empty when this query is given.\n*   `3` : Sort $A$ in ascending order.\n\n## Constraints\n\n*   $1 \\leq Q \\leq 2 \\times 10^5$\n*   $0 \\leq x \\leq 10^9$\n*   $A$ will not be empty when a query `2` is given.\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$Q$\n$\\mathrm{query} 1$\n$\\mathrm{query} 2$\n$\\vdots$\n$\\mathrm{query} Q$\n\nThe $i$\\-th query, $\\mathrm{query} i$, begins with the kind of query $c_i$ ($1$, $2$, or $3$). If $c_i = 1$, the line additionally has an integer $x$.\nIn other words, each query is in one of the three formats below.\n\n$1$ $x$\n\n$2$\n\n$3$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc217_e","tags":[],"sample_group":[["8\n1 4\n1 3\n1 2\n1 1\n3\n2\n1 0\n2","1\n2\n\nThe $i$\\-th line below shows the contents of $A$ after the $i$\\-th query is processed in Sample Input $1$.\n\n*   $(4)$\n*   $(4, 3)$\n*   $(4, 3, 2)$\n*   $(4, 3, 2, 1)$\n*   $(1, 2, 3, 4)$\n*   $(2, 3, 4)$\n*   $(2, 3, 4, 0)$\n*   $(3, 4, 0)$"],["9\n1 5\n1 5\n1 3\n2\n3\n2\n1 6\n3\n2","5\n3\n5\n\nThe $i$\\-th line below shows the contents of $A$ after the $i$\\-th query is processed in Sample Input $2$.\n\n*   $(5)$\n*   $(5, 5)$\n*   $(5, 5, 3)$\n*   $(5, 3)$\n*   $(3, 5)$\n*   $(5)$\n*   $(5, 6)$\n*   $(5, 6)$\n*   $(6)$"]],"created_at":"2026-03-03 11:01:14"}}