410463: GYM104023 H Party Animals

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Party Animalstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Macaronlin the Pony is a party animal who enjoys throwing parties for his friends. One day, he invites $$$n$$$ friends to his home party. As a party expert, he prepares a lot of games for his friends, including Multiplayer Rock-paper-scissors.

Rock-paper-scissors is a well-known game around the world, in which each player simultaneously makes one of three gestures, including rock, paper, and scissors. Rock beats scissors, scissors beats paper, and paper beats rock. If both players choose the same gesture, the game is tied.

Multiplayer Rock-paper-scissors is a multiplayer version of the original game. In this game, $$$n$$$ players are lined up in a row, numbered $$$1$$$ to $$$n$$$ from left to right. Then, the host Macaronlin will choose an interval $$$[l,r]$$$ for each round, and the players in this interval will play the game in order. Specifically, player $$$l$$$ and $$$l+1$$$ play first, then $$$l+1$$$ and $$$l+2$$$, and so on, and finally $$$r-1$$$ and $$$r$$$.

Macaronlin discovers that the strategy his friends use to play the game is very simple. Initially, each player has a preferred gesture, which is one of rock, paper, and scissors. When two players play a game, they will both use their currently preferred gestures. As soon as a player loses a game, his preferred gesture will immediately change to the gesture that beat him. Otherwise, his preferred gesture will not change, including the case where two players choose the same gesture resulting in a tie.

Macaronlin is going to hold several rounds of the game. He wants to know what a certain player's currently preferred gesture is after some rounds. Formally, there are two types of actions:

  • 1 l r: Macaronlin chooses an interval $$$[l,r]$$$, and the players in this interval will play the game in order. Specifically, player $$$l$$$ and $$$l+1$$$ play first, then $$$l+1$$$ and $$$l+2$$$, and so on, and finally $$$r-1$$$ and $$$r$$$.
  • 2 x: Macaronlin wants to know the currently preferred gesture of the player numbered $$$x$$$.

Please tell Macaronlin the answer for each action of the second type.

Input

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1\leq n,m \leq 2\times 10^5$$$), indicating the number of players and actions.

The second line contains a string of length $$$n$$$, consisting of R, P and S representing rock, paper, and scissors respectively. The $$$i$$$-th character indicates the gesture initially preferred by the player numbered $$$i$$$.

Each of the following $$$m$$$ lines indicates an action, which is either 1 l r ($$$1\leq l<r\leq n$$$) or 2 x ($$$1\leq x\leq n$$$).

Output

For each action of the second type, output a character in a single line indicating the answer, which is one of R, P and S representing rock, paper, and scissors respectively.

ExamplesInput
10 10
RPSPSSRRPS
1 1 5
1 2 6
1 3 7
1 4 8
1 2 9
2 9
2 5
1 3 6
2 8
2 3
Output
P
R
P
R
Input
10 10
SRPSPRPRPR
2 10
1 2 9
2 1
2 6
2 3
1 1 7
2 2
1 4 9
1 2 8
2 7
Output
R
S
P
S
S
S
Note

For the first sample, each action is shown as follows:

  1. $$$\underline{\texttt{RPSPS}}\texttt{SRRPS}\rightarrow\texttt{PSSSSSRRPS}$$$
  2. $$$\texttt{P}\underline{\texttt{SSSSS}}\texttt{RRPS}\rightarrow\texttt{PSSSSSRRPS}$$$
  3. $$$\texttt{PS}\underline{\texttt{SSSSR}}\texttt{RPS}\rightarrow\texttt{PSSSSRRRPS}$$$
  4. $$$\texttt{PSS}\underline{\texttt{SSRRR}}\texttt{PS}\rightarrow\texttt{PSSSRRRRPS}$$$
  5. $$$\texttt{P}\underline{\texttt{SSSRRRRP}}\texttt{S}\rightarrow\texttt{PSSRRRRPPS}$$$
  6. $$$\texttt{PSSRRRRP}[\texttt{P}]\texttt{S}$$$
  7. $$$\texttt{PSSR}[\texttt{R}]\texttt{RRPPS}$$$
  8. $$$\texttt{PS}\underline{\texttt{SRRR}}\texttt{RPPS}\rightarrow\texttt{PSRRRRRPPS}$$$
  9. $$$\texttt{PSRRRRR}[\texttt{P}]\texttt{PS}$$$
  10. $$$\texttt{PS}[\texttt{R}]\texttt{RRRRPPS}$$$

加入题单

算法标签: