{"problem":{"name":"Large RPS Tournament","description":{"content":"To decide which is the strongest among Rock, Paper, and Scissors, we will hold an RPS tournament. There are $2^k$ players in this tournament, numbered $0$ through $2^k-1$. Each player has his/her favo","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc109_c"},"statements":[{"statement_type":"Markdown","content":"To decide which is the strongest among Rock, Paper, and Scissors, we will hold an RPS tournament. There are $2^k$ players in this tournament, numbered $0$ through $2^k-1$. Each player has his/her favorite hand, which he/she will use in every match.\nA string $s$ of length $n$ consisting of `R`, `P`, and `S` represents the players' favorite hands. Specifically, the favorite hand of Player $i$ is represented by the $((i\\text{ mod } n) + 1)$\\-th character of $s$; `R`, `P`, and `S` stand for Rock, Paper, and Scissors, respectively.\nFor $l$ and $r$ such that $r-l$ is a power of $2$, the winner of the tournament held among Players $l$ through $r-1$ will be determined as follows:\n\n*   If $r-l=1$ (that is, there is just one player), the winner is Player $l$.\n*   If $r-l\\geq 2$, let $m=(l+r)/2$, and we hold two tournaments, one among Players $l$ through $m-1$ and the other among Players $m$ through $r-1$. Let $a$ and $b$ be the respective winners of these tournaments. $a$ and $b$ then play a match of rock paper scissors, and the winner of this match - or $a$ if the match is drawn - is the winner of the tournament held among Players $l$ through $r-1$.\n\nFind the favorite hand of the winner of the tournament held among Players $0$ through $2^k-1$.\n\n## Constraints\n\n*   $1 \\leq n,k \\leq 100$\n*   $s$ is a string of length $n$ consisting of `R`, `P`, and `S`.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$n$ $k$\n$s$\n\n[samples]\n\n## Notes\n\n*   $a\\text{ mod } b$ denotes the remainder when $a$ is divided by $b$.\n*   The outcome of a match of rock paper scissors is determined as follows:\n    *   If both players choose the same hand, the match is drawn;\n    *   `R` beats `S`;\n    *   `P` beats `R`;\n    *   `S` beats `P`.","is_translate":false,"language":"English"}],"meta":{"iden":"arc109_c","tags":[],"sample_group":[["3 2\nRPS","P\n\n*   The favorite hand of the winner of the tournament held among Players $0$ through $1$ is `P`.\n*   The favorite hand of the winner of the tournament held among Players $2$ through $3$ is `R`.\n*   The favorite hand of the winner of the tournament held among Players $0$ through $3$ is `P`.\n\nThus, the answer is `P`.\n\n   P\n ┌─┴─┐\n P   R\n┌┴┐ ┌┴┐\nR P S R"],["11 1\nRPSSPRSPPRS","P"],["1 100\nS","S"]],"created_at":"2026-03-03 11:01:13"}}