{"problem":{"name":"Insert or Erase","description":{"content":"You are given a sequence $A=(A_1,\\ldots,A_N)$ of length $N$. The elements of $A$ are distinct. Process $Q$ queries in the order they are given. Each query is of one of the following two types: *   `1","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc344_e"},"statements":[{"statement_type":"Markdown","content":"You are given a sequence $A=(A_1,\\ldots,A_N)$ of length $N$. The elements of $A$ are distinct.\nProcess $Q$ queries in the order they are given. Each query is of one of the following two types:\n\n*   `1 x y` : Insert $y$ immediately after the element $x$ in $A$. It is guaranteed that $x$ exists in $A$ when this query is given.\n*   `2 x` : Remove the element $x$ from $A$. It is guaranteed that $x$ exists in $A$ when this query is given.\n\nIt is guaranteed that after processing each query, $A$ will not be empty, and its elements will be distinct.\nPrint $A$ after processing all the queries.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2\\times 10^5$\n*   $1 \\leq Q \\leq 2\\times 10^5$\n*   $1 \\leq A_i \\leq 10^9$\n*   $A_i \\neq A_j$\n*   For queries of the first type, $1 \\leq x,y \\leq 10^9$.\n*   When a query of the first type is given, $x$ exists in $A$.\n*   For queries of the second type, $1 \\leq x \\leq 10^9$.\n*   When a query of the second type is given, $x$ exists in $A$.\n*   After processing each query, $A$ is not empty, and its elements are distinct.\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ \n$A_1$ $\\ldots$ $A_N$\n$Q$\n$\\mathrm{Query}_1$\n$\\vdots$ \n$\\mathrm{Query}_Q$\n\nHere, $\\mathrm{Query}_i$ represents the $i$\\-th query and is given in one of the following formats:\n\n$1$ $x$ $y$\n\n$2$ $x$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc344_e","tags":[],"sample_group":[["4\n2 1 4 3\n4\n2 1\n1 4 5\n2 2\n1 5 1","4 5 1 3\n\nThe queries are processed as follows:\n\n*   Initially, $A=(2,1,4,3)$.\n*   The first query removes $1$, making $A=(2,4,3)$.\n*   The second query inserts $5$ immediately after $4$, making $A=(2,4,5,3)$.\n*   The third query removes $2$, making $A=(4,5,3)$.\n*   The fourth query inserts $1$ immediately after $5$, making $A=(4,5,1,3)$."],["6\n3 1 4 5 9 2\n7\n2 5\n1 3 5\n1 9 7\n2 9\n2 3\n1 2 3\n2 4","5 1 7 2 3"]],"created_at":"2026-03-03 11:01:14"}}