{"problem":{"name":"Rotation","description":{"content":"You are given positive integers $N$ and $Q$, and a string $S$ of length $N$ consisting of lowercase English letters. Process $Q$ queries. Each query is of one of the following two types. *   `1 x`: P","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc258_c"},"statements":[{"statement_type":"Markdown","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$.\n\n## Constraints\n\n*   $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.\n\n## Input\n\nInput 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$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc258_c","tags":[],"sample_group":[["3 3\nabc\n2 2\n1 1\n2 2","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."],["10 8\ndsuccxulnl\n2 4\n2 7\n1 2\n2 7\n1 1\n1 2\n1 3\n2 5","c\nu\nc\nu"]],"created_at":"2026-03-03 11:01:14"}}