{"problem":{"name":"Strange Dance","description":{"content":"There are $3^N$ people dancing in circle. We denote with $0,1,\\dots, 3^{N}-1$ the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in th","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc044_c"},"statements":[{"statement_type":"Markdown","content":"There are $3^N$ people dancing in circle. We denote with $0,1,\\dots, 3^{N}-1$ the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in the circle is occupied by one person.\nThe people are going to dance on two kinds of songs: salsa and rumba.\n\n*   When a salsa is played, the person in position $i$ goes to position $j$, where $j$ is the number obtained replacing all digits $1$ with $2$ and all digits $2$ with $1$ when reading $i$ in base $3$ (e.g., the person in position $46$ goes to position $65$).\n*   When a rumba is played, the person in position $i$ moves to position $i+1$ (with the identification $3^N = 0$).\n\nYou are given a string $T=T_1T_2\\cdots T_{|T|}$ such that $T_i=$`S` if the $i$\\-th song is a salsa and $T_i=$`R` if it is a rumba. After all the songs have been played, the person that initially was in position $i$ is in position $P_i$. Compute the array $P_0,P_1,\\dots, P_{3^N-1}$.\n\n## Constraints\n\n*   $1 \\le N \\le 12$\n*   $1 \\le |T| \\le 200,000$\n*   $T$ contains only the characters `S` and `R`.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$T$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc044_c","tags":[],"sample_group":[["1\nSRS","2 0 1 \n\nBefore any song is played, the positions are: $0$, $1$, $2$.\nWhen we say \"person $i$\", we mean \"the person that was initially in position $i$\".\n\n1.  After the first salsa, the positions are: $0$, $2$, $1$.\n2.  After the rumba, the positions are: $1$, $0$, $2$ (so, person $0$ is in position $1$, person $1$ is in position $0$ and person $2$ is in position $2$).\n3.  After the second salsa, the positions are $2$, $0$, $1$ (so, person $0$ is in position $2$, person $1$ is in position $0$ and person $2$ is in position $1$)."],["2\nRRSRSSSSR","3 8 1 0 5 7 6 2 4"],["3\nSRSRRSRRRSRRRR","23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"]],"created_at":"2026-03-03 11:01:13"}}