{"raw_statement":[{"iden":"problem statement","content":"You are given a string $S$ of length $N$ consisting of lowercase English letters. Each character of $S$ is painted in one of the $M$ colors: color $1$, color $2$, ..., color $M$; for each $i = 1, 2, \\ldots, N$, the $i$\\-th character of $S$ is painted in color $C_i$.\nFor each $i = 1, 2, \\ldots, M$ in this order, let us perform the following operation.\n\n*   Perform a right circular shift by $1$ on the part of $S$ painted in color $i$. That is, if the $p_1$\\-th, $p_2$\\-th, $p_3$\\-th, $\\ldots$, $p_k$\\-th characters are painted in color $i$ from left to right, then simultaneously replace the $p_1$\\-th, $p_2$\\-th, $p_3$\\-th, $\\ldots$, $p_k$\\-th characters of $S$ with the $p_k$\\-th, $p_1$\\-th, $p_2$\\-th, $\\ldots$, $p_{k-1}$\\-th characters of $S$, respectively.\n\nPrint the final $S$ after the above operations.\nThe constraints guarantee that at least one character of $S$ is painted in each of the $M$ colors."},{"iden":"constraints","content":"*   $1 \\leq M \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq C_i \\leq M$\n*   $N$, $M$, and $C_i$ are all integers.\n*   $S$ is a string of length $N$ consisting of lowercase English letters.\n*   For each integer $1 \\leq i \\leq M$, there is an integer $1 \\leq j \\leq N$ such that $C_j = i$."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $M$\n$S$\n$C_1$ $C_2$ $\\ldots$ $C_N$"},{"iden":"sample input 1","content":"8 3\napzbqrcs\n1 2 3 1 2 2 1 2"},{"iden":"sample output 1","content":"cszapqbr\n\nInitially, $S = $ `apzbqrcs`.\n\n*   For $i = 1$, perform a right circular shift by $1$ on the part of $S$ formed by the $1$\\-st, $4$\\-th, $7$\\-th characters, resulting in $S = $ `cpzaqrbs`.\n*   For $i = 2$, perform a right circular shift by $1$ on the part of $S$ formed by the $2$\\-nd, $5$\\-th, $6$\\-th, $8$\\-th characters, resulting in $S = $ `cszapqbr`.\n*   For $i = 3$, perform a right circular shift by $1$ on the part of $S$ formed by the $3$\\-rd character, resulting in $S = $ `cszapqbr` (here, $S$ is not changed).\n\nThus, you should print `cszapqbr`, the final $S$."},{"iden":"sample input 2","content":"2 1\naa\n1 1"},{"iden":"sample output 2","content":"aa"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}