{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eRecently, you found a bot to play \"Rock paper scissors\" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $$$s \u003d s_1 s_2 \\dots s_{n}$$$ of length $$$n$$$ where each letter is either \u003cspan class\u003d\"tex-font-style-tt\"\u003eR\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eS\u003c/span\u003e or \u003cspan class\u003d\"tex-font-style-tt\"\u003eP\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eWhile initializing, the bot is choosing a starting index $$$pos$$$ ($$$1 \\le pos \\le n$$$), and then it can play any number of rounds. In the first round, he chooses \"Rock\", \"Scissors\" or \"Paper\" based on the value of $$$s_{pos}$$$: \u003c/p\u003e\u003cul\u003e \u003cli\u003e if $$$s_{pos}$$$ is equal to \u003cspan class\u003d\"tex-font-style-tt\"\u003eR\u003c/span\u003e the bot chooses \"Rock\"; \u003c/li\u003e\u003cli\u003e if $$$s_{pos}$$$ is equal to \u003cspan class\u003d\"tex-font-style-tt\"\u003eS\u003c/span\u003e the bot chooses \"Scissors\"; \u003c/li\u003e\u003cli\u003e if $$$s_{pos}$$$ is equal to \u003cspan class\u003d\"tex-font-style-tt\"\u003eP\u003c/span\u003e the bot chooses \"Paper\"; \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eIn the second round, the bot\u0027s choice is based on the value of $$$s_{pos + 1}$$$. In the third round\u0026nbsp;— on $$$s_{pos + 2}$$$ and so on. After $$$s_n$$$ the bot returns to $$$s_1$$$ and continues his game.\u003c/p\u003e\u003cp\u003eYou plan to play $$$n$$$ rounds and you\u0027ve already figured out the string $$$s$$$ but still don\u0027t know what is the starting index $$$pos$$$. But since the bot\u0027s tactic is so boring, you\u0027ve decided to find $$$n$$$ choices to each round to maximize the average number of wins.\u003c/p\u003e\u003cp\u003eIn other words, let\u0027s suggest your choices are $$$c_1 c_2 \\dots c_n$$$ and if the bot starts from index $$$pos$$$ then you\u0027ll win in $$$win(pos)$$$ rounds. Find $$$c_1 c_2 \\dots c_n$$$ such that $$$\\frac{win(1) + win(2) + \\dots + win(n)}{n}$$$ is maximum possible.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 1000$$$)\u0026nbsp;— the number of test cases.\u003c/p\u003e\u003cp\u003eNext $$$t$$$ lines contain test cases\u0026nbsp;— one per line. The first and only line of each test case contains string $$$s \u003d s_1 s_2 \\dots s_{n}$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$; $$$s_i \\in \\{\\text{R}, \\text{S}, \\text{P}\\}$$$)\u0026nbsp;— the string of the bot.\u003c/p\u003e\u003cp\u003eIt\u0027s guaranteed that the total length of all strings in one test doesn\u0027t exceed $$$2 \\cdot 10^5$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, print $$$n$$$ choices $$$c_1 c_2 \\dots c_n$$$ to maximize the average number of wins. Print them in the same manner as the string $$$s$$$.\u003c/p\u003e\u003cp\u003eIf there are multiple optimal answers, print any of them.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\nRRRR\nRSP\nS\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003ePPPP\nRSP\nR\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, the bot (wherever it starts) will always choose \"Rock\", so we can always choose \"Paper\". So, in any case, we will win all $$$n \u003d 4$$$ rounds, so the average is also equal to $$$4$$$.\u003c/p\u003e\u003cp\u003eIn the second test case: \u003c/p\u003e\u003cul\u003e \u003cli\u003e if bot will start from $$$pos \u003d 1$$$, then $$$(s_1, c_1)$$$ is draw, $$$(s_2, c_2)$$$ is draw and $$$(s_3, c_3)$$$ is draw, so $$$win(1) \u003d 0$$$; \u003c/li\u003e\u003cli\u003e if bot will start from $$$pos \u003d 2$$$, then $$$(s_2, c_1)$$$ is win, $$$(s_3, c_2)$$$ is win and $$$(s_1, c_3)$$$ is win, so $$$win(2) \u003d 3$$$; \u003c/li\u003e\u003cli\u003e if bot will start from $$$pos \u003d 3$$$, then $$$(s_3, c_1)$$$ is lose, $$$(s_1, c_2)$$$ is lose and $$$(s_2, c_3)$$$ is lose, so $$$win(3) \u003d 0$$$; \u003c/li\u003e\u003c/ul\u003e The average is equal to $$$\\frac{0 + 3 + 0}{3} \u003d 1$$$ and it can be proven that it\u0027s the maximum possible average.\u003cp\u003eA picture from Wikipedia explaining \"Rock paper scissors\" game: \u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/74fe861a99cd006010a08302c39b2de9?v\u003d1715652822\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e"}}]}