{"problem":{"name":"Writing a Numeral","description":{"content":"We have a string $S$. Initially, $S=$ `1`.   Process $Q$ queries in the following formats in order. *   `1 x` : Append a digit $x$ at the end of $S$. *   `2` : Delete the digit at the beginning of $S","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc298_d"},"statements":[{"statement_type":"Markdown","content":"We have a string $S$. Initially, $S=$ `1`.  \nProcess $Q$ queries in the following formats in order.\n\n*   `1 x` : Append a digit $x$ at the end of $S$.\n*   `2` : Delete the digit at the beginning of $S$.\n*   `3` : Print the number represented by $S$ in decimal, modulo $998244353$.\n\n## Constraints\n\n*   $1 \\leq Q \\leq 6 \\times 10^5$\n*   For each query in the first format, $x \\in {1,2,3,4,5,6,7,8,9}$.\n*   A query in the second format is given only if $S$ has a length of $2$ or greater.\n*   There is at least one query in the third format.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$Q$\n$\\mathrm{query}_1$\n$\\vdots$\n$\\mathrm{query}_Q$\n\nHere, $\\mathrm{query}_i$ denotes the $i$\\-th query, which is in one of the following formats:\n\n$1$ $x$\n\n$2$\n\n$3$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc298_d","tags":[],"sample_group":[["3\n3\n1 2\n3","1\n12\n\nIn the first query, $S$ is `1`, so you should print $1$ modulo $998244353$, that is, $1$.  \nIn the second query, $S$ becomes `12`.  \nIn the third query, $S$ is `12`, so you should print $12$ modulo $998244353$, that is, $12$."],["3\n1 5\n2\n3","5"],["11\n1 9\n1 9\n1 8\n1 2\n1 4\n1 4\n1 3\n1 5\n1 3\n2\n3","0\n\nBe sure to print numbers modulo $998244353$."]],"created_at":"2026-03-03 11:01:14"}}