{"raw_statement":[{"iden":"problem statement","content":"You are given positive integers $N$ and $Q$, and a string $S$ of length $N$ consisting of lowercase English letters.\nProcess $Q$ queries. Each query is of one of the following two types.\n\n*   `1 x`: Perform the following $x$ times in a row: delete the last character of $S$ and append it to the beginning.\n*   `2 x`: Print the $x$\\-th character of $S$."},{"iden":"constraints","content":"*   $2 \\le N \\le 5 \\times 10^5$\n*   $1 \\le Q \\le 5 \\times 10^5$\n*   $1 \\le x \\le N$\n*   $|S|=N$\n*   $S$ consists of lowercase English letters.\n*   At least one query in the format `2 x`.\n*   $N$, $Q$, $x$ are all integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $Q$\n$S$\n$\\mathrm{query}_1$\n$\\mathrm{query}_2$\n$\\vdots$\n$\\mathrm{query}_Q$\n\nEach query is in the following format, where $t$ is $1$ or $2$:\n\n$t$ $x$"},{"iden":"sample input 1","content":"3 3\nabc\n2 2\n1 1\n2 2"},{"iden":"sample output 1","content":"b\na\n\nIn the $1$\\-st query, $S$ is `abc`, so the $2$\\-nd character `b` should be printed. In the $2$\\-nd query, $S$ is changed from `abc` to `cab`. In the $3$\\-rd query, $S$ is `cab`, so the $2$\\-nd character `a` should be printed."},{"iden":"sample input 2","content":"10 8\ndsuccxulnl\n2 4\n2 7\n1 2\n2 7\n1 1\n1 2\n1 3\n2 5"},{"iden":"sample output 2","content":"c\nu\nc\nu"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}