#arc109c. [arc109_c]Large RPS Tournament

[arc109_c]Large RPS Tournament

Problem Statement

To decide which is the strongest among Rock, Paper, and Scissors, we will hold an RPS tournament. There are 2k2^k players in this tournament, numbered 00 through 2k12^k-1. Each player has his/her favorite hand, which he/she will use in every match.

A string ss of length nn consisting of R, P, and S represents the players' favorite hands. Specifically, the favorite hand of Player ii is represented by the ((itextmodn)+1)((i\\text{ mod } n) + 1)-th character of ss; R, P, and S stand for Rock, Paper, and Scissors, respectively.

For ll and rr such that rlr-l is a power of 22, the winner of the tournament held among Players ll through r1r-1 will be determined as follows:

  • If rl=1r-l=1 (that is, there is just one player), the winner is Player ll.
  • If rlgeq2r-l\\geq 2, let m=(l+r)/2m=(l+r)/2, and we hold two tournaments, one among Players ll through m1m-1 and the other among Players mm through r1r-1. Let aa and bb be the respective winners of these tournaments. aa and bb then play a match of rock paper scissors, and the winner of this match - or aa if the match is drawn - is the winner of the tournament held among Players ll through r1r-1.

Find the favorite hand of the winner of the tournament held among Players 00 through 2k12^k-1.

Notes

  • atextmodba\\text{ mod } b denotes the remainder when aa is divided by bb.
  • The outcome of a match of rock paper scissors is determined as follows:
    • If both players choose the same hand, the match is drawn;
    • R beats S;
    • P beats R;
    • S beats P.

Constraints

  • 1leqn,kleq1001 \\leq n,k \\leq 100
  • ss is a string of length nn consisting of R, P, and S.

Input

Input is given from Standard Input in the following format:

nn kk ss

Output

Print the favorite hand of the winner of the tournament held among Players 00 through 2k12^k-1, as R, P, or S.


Sample Input 1

3 2
RPS

Sample Output 1

P
  • The favorite hand of the winner of the tournament held among Players 00 through 11 is P.
  • The favorite hand of the winner of the tournament held among Players 22 through 33 is R.
  • The favorite hand of the winner of the tournament held among Players 00 through 33 is P.

Thus, the answer is P.

   P
 ┌─┴─┐
 P   R
┌┴┐ ┌┴┐
R P S R

Sample Input 2

11 1
RPSSPRSPPRS

Sample Output 2

P

Sample Input 3

1 100
S

Sample Output 3

S