{"raw_statement":[{"iden":"problem statement","content":"Takahashi has a string $S$ consisting of lowercase English letters.\nStarting with this string, he will produce a new one in the procedure given as follows.\nThe procedure consists of $Q$ operations. In Operation $i$ $(1 \\leq i \\leq Q)$, an integer $T_i$ is provided, which means the following:\n\n*   If $T_i = 1$: reverse the string $S$.\n    \n*   If $T_i = 2$: An integer $F_i$ and a lowercase English letter $C_i$ are additionally provided.\n    *   If $F_i = 1$ : Add $C_i$ to the beginning of the string $S$.\n    *   If $F_i = 2$ : Add $C_i$ to the end of the string $S$.\n\nHelp Takahashi by finding the final string that results from the procedure."},{"iden":"constraints","content":"*   $1 \\leq |S| \\leq 10^5$\n*   $S$ consists of lowercase English letters.\n*   $1 \\leq Q \\leq 2 \\times 10^5$\n*   $T_i = 1$ or $2$.\n*   $F_i = 1$ or $2$, if provided.\n*   $C_i$ is a lowercase English letter, if provided."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$S$\n$Q$\n$Query_1$\n$:$\n$Query_Q$\n\nIn the $3$\\-rd through the $(Q+2)$\\-th lines, $Query_i$ is one of the following:\n\n$1$\n\nwhich means $T_i = 1$, and:\n\n$2$ $F_i$ $C_i$\n\nwhich means $T_i = 2$."},{"iden":"sample input 1","content":"a\n4\n2 1 p\n1\n2 2 c\n1"},{"iden":"sample output 1","content":"cpa\n\nThere will be $Q = 4$ operations. Initially, $S$ is `a`.\n\n*   Operation $1$: Add `p` at the beginning of $S$. $S$ becomes `pa`.\n    \n*   Operation $2$: Reverse $S$. $S$ becomes `ap`.\n    \n*   Operation $3$: Add `c` at the end of $S$. $S$ becomes `apc`.\n    \n*   Operation $4$: Reverse $S$. $S$ becomes `cpa`.\n    \n\nThus, the resulting string is `cpa`."},{"iden":"sample input 2","content":"a\n6\n2 2 a\n2 1 b\n1\n2 2 c\n1\n1"},{"iden":"sample output 2","content":"aabc\n\nThere will be $Q = 6$ operations. Initially, $S$ is `a`.\n\n*   Operation $1$: $S$ becomes `aa`.\n    \n*   Operation $2$: $S$ becomes `baa`.\n    \n*   Operation $3$: $S$ becomes `aab`.\n    \n*   Operation $4$: $S$ becomes `aabc`.\n    \n*   Operation $5$: $S$ becomes `cbaa`.\n    \n*   Operation $6$: $S$ becomes `aabc`.\n    \n\nThus, the resulting string is `aabc`."},{"iden":"sample input 3","content":"y\n1\n2 1 x"},{"iden":"sample output 3","content":"xy"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}