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.
A 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.
For 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:
 - If r-l=1 (that is, there is just one player), the winner is Player l.
 - 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.
Find the favorite hand of the winner of the tournament held among Players 0 through 2^k-1.

-----Notes-----
 - a\text{ mod } b denotes the remainder when a is divided by b.
 - 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-----
 - 1 \leq n,k \leq 100
 - s is a string of length n consisting of R, P, and S.

-----Input-----
Input is given from Standard Input in the following format:
n k
s

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

-----Sample Input-----
3 2
RPS

-----Sample Output-----
P

 - The favorite hand of the winner of the tournament held among Players 0 through 1 is P.
 - The favorite hand of the winner of the tournament held among Players 2 through 3 is R.
 - The favorite hand of the winner of the tournament held among Players 0 through 3 is P.
Thus, the answer is P.
   P
 ┌─┴─┐
 P   R
┌┴┐ ┌┴┐
R P S R
 ```
       S
   ┌───┴───┐
   P       S
 ┌─┴─┐   ┌─┴─┐
 P   R   S   P
┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐
R P S R P S R P
```

Difficulty: MEDIUM_HARD

Solutions:
from typing import List

def winner(a: str, b: str) -> str:
	return b if (a, b) in [('R', 'P'), ('P', 'S'), ('S', 'R')] else a
(N, K) = list(map(int, input().split()))
S: List[str] = list(input())
for i in range(K):
	T: List[str] = S + S
	S = [winner(T[2 * j], T[2 * j + 1]) for j in range(N)]
print(S[0])


win = {'R': 'P', 'P': 'S', 'S': 'R'}
(n, k) = list(map(int, input().split()))
S = input()
for _ in range(k):
	t = S + S
	for i in range(n):
		a = t[i * 2]
		b = t[i * 2 + 1]
		S = S[:i] + (b if win[a] == b else a) + S[i + 1:]
print(S[0])


def win(x, y):
	if x + y in ['PR', 'RP', 'PP']:
		return 'P'
	if x + y in ['SR', 'RS', 'RR']:
		return 'R'
	if x + y in ['SP', 'PS', 'SS']:
		return 'S'
(n, k) = list(map(int, input().split()))
s = list(input()[::-1]) * 2
for _ in range(k):
	tmp = []
	while s:
		(i, j) = (s.pop(), s.pop())
		tmp.append(win(i, j))
	s = tmp[::-1] * 2
print(s.pop())


def RPS(a, b):
	if a == b:
		return a
	elif a == 'R' and b == 'S':
		return a
	elif a == 'P' and b == 'R':
		return a
	elif a == 'S' and b == 'P':
		return a
	else:
		return b
(n, k) = map(int, input().split())
s = input()
while k > 0:
	t = s + s
	s = []
	for i in range(0, len(t), 2):
		s.append(RPS(t[i], t[i + 1]))
	k -= 1
print(s[0])


(N, K) = map(int, input().split())
s = input()
S = s * 4
D = {}
D['R', 'R'] = 'R'
D['R', 'S'] = 'R'
D['S', 'R'] = 'R'
D['S', 'S'] = 'S'
D['S', 'P'] = 'S'
D['P', 'S'] = 'S'
D['P', 'P'] = 'P'
D['P', 'R'] = 'P'
D['R', 'P'] = 'P'
for i in range(K):
	A = ''
	for j in range(len(S) // 2):
		A += D[S[2 * j], S[2 * j + 1]]
	S = A * 2
print(S[0])


(n, k) = list(map(int, input().split()))
s = input()
for _ in range(k):
	tmp = ''
	for i in range(0, 2 * n, 2):
		s1 = s[i % n]
		s2 = s[(i + 1) % n]
		if s1 == s2:
			tmp += s1
		elif (s1, s2) in (('R', 'S'), ('S', 'R')):
			tmp += 'R'
		elif (s1, s2) in (('P', 'S'), ('S', 'P')):
			tmp += 'S'
		else:
			tmp += 'P'
	s = tmp
print(s[0])


(n, k) = map(int, input().split())
s = input()
import sys
sys.setrecursionlimit(10 ** 5)
memo = [[None for i in range(k + 1)] for j in range(n)]

def f(x, y):
	if memo[x][y] != None:
		return memo[x][y]
	if y == 0:
		ans = s[x]
	else:
		l = f(x, y - 1)
		r = f((x + 2 ** (y - 1)) % n, y - 1)
		p = set([l, r])
		if len(p) == 1:
			ans = l
		elif 'R' not in p:
			ans = 'S'
		elif 'S' not in p:
			ans = 'P'
		else:
			ans = 'R'
	memo[x][y] = ans
	return ans
print(f(0, k))


(n, k) = map(int, input().split())
s = list(input())
judge_d = [[0, 0, 2], [0, 1, 1], [2, 1, 2]]
name_to_ind = {'R': 0, 'S': 1, 'P': 2}
ind_to_name = ['R', 'S', 'P']

def judge(a, b):
	(a, b) = (name_to_ind[a], name_to_ind[b])
	ind = judge_d[a][b]
	return ind_to_name[ind]

def Rec(s, k):
	if k == 1:
		if len(s) == 1:
			s = s + s
		print(judge(s[0], s[1]))
	else:
		if len(s) % 2 == 1:
			s = s + s
		l = len(s) // 2
		S = []
		for i in range(l):
			S.append(judge(s[i * 2], s[i * 2 + 1]))
		Rec(S, k - 1)
Rec(s, k)


R = 'R'
S = 'S'
P = 'P'

def winner(a, b):
	if a == b:
		return a
	if a != R and b != R:
		return S
	if a != S and b != S:
		return P
	if a != P and b != P:
		return R
(n, k) = map(int, input().split())
s = input()
s = s + s
for _ in range(k):
	ns = ''
	for i in range(n):
		ns += winner(s[2 * i], s[2 * i + 1])
	s = ns + ns
print(s[0])


(n, k) = [int(x) for x in input().split()]
s = input()
import copy
for i in range(k):
	t = []
	if n % 2 == 1:
		n *= 2
		s = s * 2
	for j in range(int(n / 2)):
		if s[2 * j] == 'R' and s[2 * j + 1] == 'S' or (s[2 * j] == 'S' and s[2 * j + 1] == 'R'):
			t.append('R')
		elif s[2 * j] == 'R' and s[2 * j + 1] == 'P' or (s[2 * j] == 'P' and s[2 * j + 1] == 'R'):
			t.append('P')
		elif s[2 * j] == 'S' and s[2 * j + 1] == 'P' or (s[2 * j] == 'P' and s[2 * j + 1] == 'S'):
			t.append('S')
		else:
			t.append(s[2 * j])
	n /= 2
	s = copy.deepcopy(t)
print(s[0])


(n, k) = map(int, input().split())
S = input()

def battle(h1, h2):
	return h1 if h2 + h1 in 'SRPS' else h2
dp = [[0] * n for _ in range(k + 1)]
dp[0] = list(S[:])
for i in range(1, k + 1):
	for j in range(n):
		dp[i][j] = battle(dp[i - 1][j], dp[i - 1][(j + pow(2, i - 1)) % n])
print(dp[k][0])


(n, k) = map(int, input().split())
s = list(input())
d = dict()
(d['R', 'S'], d['S', 'R']) = ('R', 'R')
(d['P', 'R'], d['R', 'P']) = ('P', 'P')
(d['S', 'P'], d['P', 'S']) = ('S', 'S')
(d['R', 'R'], d['P', 'P'], d['S', 'S']) = ('R', 'P', 'S')
t = s + s
for _ in range(k):
	for i in range(n):
		t[i] = d[t[2 * i], t[2 * i + 1]]
	for i in range(n):
		t[n + i] = t[i]
ans = t[0]
print(ans)


(n, k) = list(map(int, input().split()))
s = input()
s += s

def judge(a, b):
	if a == 'S' and b == 'R' or (a == 'R' and b == 'P') or (a == 'P' and b == 'S'):
		return b
	else:
		return a
hands = [''] * (2 * n)
for i in range(len(s)):
	hands[i] = s[i]
for i in range(k):
	for j in range(n):
		hands[j] = judge(hands[2 * j], hands[2 * j + 1])
	hands[n:] = hands[:n]
print(hands[0])


(n, k) = list(map(int, input().split()))
s = list(input()[::-1]) * 2
(ptn, win) = ('PRPP_RSRR_SPSS', 'PRS')
for _ in range(k):
	tmp = []
	while s:
		hand = ptn.index(s.pop() + s.pop())
		tmp.append(win[hand // 5])
	s = tmp[::-1] * 2
print(s.pop())


def win(a, b):
	w = a
	if a == 'R' and b == 'P':
		w = b
	if a == 'P' and b == 'S':
		w = b
	if a == 'S' and b == 'R':
		w = b
	return w
(n, k) = list(map(int, input().split()))
dp = [[c for c in input()]]
for i in range(k):
	dp.append([*dp[i]])
	for j in range(n):
		dp[i + 1][j] = win(dp[i][j * 2 % n], dp[i][(j * 2 + 1) % n])
print(dp[k][0])


(n, k) = map(int, input().rstrip().split(' '))
S = list(input())

def Game(a, b):
	if a == b:
		win = a
	elif a == 'R':
		if b == 'S':
			win = a
		else:
			win = b
	elif a == 'S':
		if b == 'P':
			win = a
		else:
			win = b
	elif b == 'R':
		win = a
	else:
		win = b
	return win
T = S
l = len(T)
for i in range(k):
	U = T + T
	l = len(U)
	for j in range(0, l, 2):
		T[j // 2] = Game(U[j], U[j + 1])
print(T[0])


from sys import stdin, setrecursionlimit
import bisect, collections, copy, heapq, itertools, math, string
setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 1000000007

def input():
	return stdin.readline().strip()

def main():
	dic = dict()

	def solve(l, r, i):
		if (i, r - l) in dic:
			return dic[i, r - l]
		if r - l == 1:
			return s[i]
		mid = (l + r) // 2
		a = solve(l, mid, i)
		b = solve(mid, r, (i + mid - l) % n)
		res = ''
		st = {a, b}
		if st == set('RS'):
			res = 'R'
		elif st == set('PR'):
			res = 'P'
		elif st == set('SP'):
			res = 'S'
		else:
			res = a
		dic[i, r - l] = res
		return res
	(n, k) = list(map(int, input().split()))
	s = input()
	ans = solve(0, pow(2, k), 0)
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
S = input()
d = [list(S) for _ in range(k + 1)]
for i in range(k):
	for j in range(n):
		a = d[i][j]
		b = d[i][(j + pow(2, i)) % n]
		d[i + 1][j] = a if b + a in 'SRPS' else b
print(d[k][0])


def winner(x, y):
	return x if x + y in ['RS', 'PR', 'SP'] else y
(n, k) = list(map(int, input().split()))
s = input()
for _ in range(k):
	if len(s) % 2 == 1:
		s += s
	s = ''.join((winner(s[2 * i], s[2 * i + 1]) for i in range(len(s) // 2)))
print(s[0])


(n, k) = list(map(int, input().split()))
s = input()
if n == 1:
	print(s)
	return
dic = {}
dic['RR'] = 'R'
dic['SS'] = 'S'
dic['PP'] = 'P'
dic['RP'] = 'P'
dic['PR'] = 'P'
dic['PS'] = 'S'
dic['SP'] = 'S'
dic['RS'] = 'R'
dic['SR'] = 'R'
dp = [[-1] * n for i in range(110)]
ss = s * 2
for i in range(n):
	dp[1][i] = dic[ss[i:i + 2]]

def f(i, j):
	if dp[i][j] != -1:
		return dp[i][j]
	else:
		dp[i][j] = dic[f(i - 1, j) + f(i - 1, (pow(2, i - 1) + j) % n)]
		return dp[i][j]
print(f(k, 0))


t = input
(N, K) = map(int, t().split())
S = t() * 2
for k in range(K):
	T = ''
	for i in range(N):
		T += 'P_PSRRS'[ord(S[i * 2]) + ord(S[i * 2 + 1]) - 160]
	S = T * 2
print(S[0])


def win(a, b):
	w = a
	if a == 'R' and b == 'P':
		w = b
	if a == 'P' and b == 'S':
		w = b
	if a == 'S' and b == 'R':
		w = b
	return w
(n, k) = list(map(int, input().split()))
S = input()
for _ in range(k):
	t = S + S
	for i in range(n):
		S = S[:i] + win(t[i * 2], t[i * 2 + 1]) + S[i + 1:]
print(S[0])


import sys
sys.setrecursionlimit(10 ** 7)

def getnum(t=int):
	return t(sys.stdin.buffer.readline())

def numline(t=int):
	return map(t, sys.stdin.buffer.readline().split())

def numread(t=int):
	return map(t, sys.stdin.buffer.read().split())

def getstr():
	return sys.stdin.readline().strip()

def strline():
	return sys.stdin.readline().strip().split()

def strread():
	return sys.stdin.read().strip().split()
import math

def main():
	(n, k, s) = strread()
	(N, K) = (int(n), int(k))
	rel = {(w, w): w for w in 'RSP'}
	rel['R', 'S'] = 'R'
	rel['R', 'P'] = 'P'
	rel['S', 'P'] = 'S'
	for (a, b) in list(rel.keys()):
		rel[b, a] = rel[a, b]
	for k in range(K, 0, -1):
		if len(s) % 2:
			s = s + s
		next_s = ''
		for i in range(0, len(s), 2):
			next_s += rel[s[i], s[i + 1]]
		if math.log2(len(next_s)) > k - 1:
			next_s = next_s[:2 ** (k - 1)]
		s = next_s
	print(s[0])

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
s = input()

def f(x, y):
	if x == y:
		return x
	elif (x, y) == ('R', 'S') or (x, y) == ('S', 'P') or (x, y) == ('P', 'R'):
		return x
	else:
		return y
dp = [[''] * n for _ in range(k + 1)]
for i in range(n):
	dp[0][i] = s[i]

def g(x, k):
	if dp[k][x] != '':
		return dp[k][x]
	a = x % n
	b = (x + pow(2, k - 1, n)) % n
	p = g(a, k - 1)
	q = g(b, k - 1)
	dp[k][x] = f(p, q)
	return dp[k][x]
g(0, k)
print(dp[k][0])


(n, k) = map(int, input().split())
S = list(input())
hands = ['R', 'P', 'S']
for i in range(len(S)):
	S[i] = hands.index(S[i])

def judge(a, b):
	(a, b) = (max(a, b), min(a, b))
	if (a, b) == (2, 0):
		return b
	else:
		return a
for _ in range(k):
	S += S
	T = []
	for i in range(1, len(S), 2):
		T.append(judge(S[i - 1], S[i]))
	S = T
print(hands[T[0]])


def rps(x, y):
	if x == 'R' and y == 'P':
		return y
	if x == 'P' and y == 'S':
		return y
	if x == 'S' and y == 'R':
		return y
	else:
		return x
(n, k) = map(int, input().split())
s = input()
S = s + s
for i in range(k):
	tmp = []
	for j in range(0, len(S), 2):
		tmp.append(rps(S[j], S[j + 1]))
	S = tmp + tmp
print(S[0])


(n, k) = map(int, input().split())
s = input()

def win(x, y):
	if x == y:
		return x
	else:
		hands = [x, y]
		if 'R' not in hands:
			return 'S'
		elif 'S' not in hands:
			return 'P'
		else:
			return 'R'
for _ in range(k):
	t = s + s
	s = []
	for i in range(n):
		s.append(win(t[i * 2], t[i * 2 + 1]))
print(s[0])


(N, K) = list(map(int, input().split()))
S = input()

def judge(a, b):
	win = a
	if a + b == 'RP':
		win = b
	elif a + b == 'PS':
		win = b
	elif a + b == 'SR':
		win = b
	return win
memo = [[''] * (N + 5) for _ in range(K + 5)]

def rec(k, i):
	if memo[k][i]:
		return memo[k][i]
	if k == 0:
		ret = judge(S[i % N], S[(i + 1) % N])
		memo[k][i] = ret
		return ret
	win = judge(rec(k - 1, i % N), rec(k - 1, (i + pow(2, k, N)) % N))
	memo[k][i] = win
	return win
ans = rec(K - 1, 0)
print(ans)


def main():
	(n, k) = map(int, input().split())
	s = input()
	s += s
	for i in range(k):
		tmp = ''
		for j in range(0, 2 * n, 2):
			if s[j] == s[j + 1]:
				tmp += s[j]
			elif s[j] == 'R':
				if s[j + 1] == 'S':
					tmp += s[j]
				else:
					tmp += s[j + 1]
			elif s[j] == 'P':
				if s[j + 1] == 'R':
					tmp += s[j]
				else:
					tmp += s[j + 1]
			elif s[j + 1] == 'P':
				tmp += s[j]
			else:
				tmp += s[j + 1]
		s = tmp + tmp
	print(s[0])

def __starting_point():
	main()
__starting_point()


def merge(x, y):
	if x == y:
		return x
	if x != 'R' and y != 'R':
		return 'S'
	if x != 'P' and y != 'P':
		return 'R'
	return 'P'

def main():
	(n, k) = list(map(int, input().split()))
	S = input()
	cur = S
	for i in range(k):
		prev = cur
		cur = [None] * n
		for j in range(n):
			cur[j] = merge(prev[j * 2 % n], prev[(j * 2 + 1) % n])
	print(cur[0])

def __starting_point():
	main()
__starting_point()


import sys
sys.setrecursionlimit(5000)
(n, k) = list(map(int, input().split()))
s = input()
win = {'R': 'S', 'P': 'R', 'S': 'P'}
memo = [[-1] * (k + 1) for _ in range(n + 1)]

def rec(idx, k):
	if k == 0:
		return s[idx]
	if memo[idx][k] != -1:
		return memo[idx][k]
	idxr = (idx + pow(2, k - 1)) % n
	lte = rec(idx, k - 1)
	rte = rec(idxr, k - 1)
	if lte == rte:
		winte = lte
	elif win[lte] == rte:
		winte = lte
	else:
		winte = rte
	memo[idx][k] = winte
	return winte
w = rec(0, k)
print(w)


from re import split

def main():
	(_, k) = list(map(int, input().split()))
	s = list(input())
	new_s = []
	for i in range(k):
		if len(s) % 2 == 1:
			s = s * 2
		s = [s[2 * i:2 * i + 2] for i in range(len(s) // 2)]
		for l in s:
			if l[0] == 'R':
				if l[1] == 'P':
					new_s.append('P')
				else:
					new_s.append('R')
			elif l[0] == 'S':
				if l[1] == 'R':
					new_s.append('R')
				else:
					new_s.append('S')
			if l[0] == 'P':
				if l[1] == 'S':
					new_s.append('S')
				else:
					new_s.append('P')
		s = new_s
		new_s = []
	print(s[0])
main()


from bisect import bisect_left, bisect_right, insort_left
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush, heappushpop
from itertools import combinations, permutations
from math import gcd, factorial, log2
from pprint import pprint
from sys import setrecursionlimit
from time import time
setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
INF = 10 ** 18
(n, k) = list(map(int, input().split()))
s = input()
memo = [[None] * n for _ in range(k + 1)]

def win(a, b):
	_a = s[a % n]
	_b = s[b % n]
	win
	if _a == _b:
		return a
	if _a == 'R':
		return a if _b == 'S' else b
	if _a == 'P':
		return a if _b == 'R' else b
	if _a == 'S':
		return a if _b == 'P' else b
cnt = 0

def recur(a, b):
	nonlocal cnt
	cnt += 1
	if memo[int(log2(b - a))][a % n] is not None:
		return a + memo[int(log2(b - a))][a % n]
	else:
		if b - a <= 2:
			winner = win(a, b - 1)
		else:
			winner = win(recur(a, (a + b) // 2), recur((a + b) // 2, b))
		memo[int(log2(b - a))][a % n] = winner % (b - a)
		return winner
print(s[recur(0, 2 ** k) % n])


(N, K) = map(int, input().split())
S = input()
for i in range(K):
	S = S + S
	t = ''
	for j in range(0, 2 * N, 2):
		if S[j] == 'R' and (S[j + 1] == 'S' or S[j + 1] == 'R') or (S[j] == 'S' and S[j + 1] == 'R'):
			t += 'R'
		elif S[j] == 'S' and (S[j + 1] == 'S' or S[j + 1] == 'P') or (S[j] == 'P' and S[j + 1] == 'S'):
			t += 'S'
		else:
			t += 'P'
	S = t
print(S[0])


(N, k) = map(int, input().split())
S = list(input())

def zyanken(a, b):
	if a == 'R':
		if b == 'P':
			return 'P'
		else:
			return 'R'
	elif a == 'S':
		if b == 'R':
			return 'R'
		else:
			return 'S'
	elif a == 'P':
		if b == 'S':
			return 'S'
		else:
			return 'P'
now = k
f = 0
if N == 1:
	print(S[0])
else:
	while now > 0:
		T = S + S
		for i in range(0, N):
			S[i] = zyanken(str(T[i * 2 % N]), str(T[(2 * i + 1) % N]))
		now -= 1
	print(S[0])


import sys, math, random, re, heapq
from itertools import combinations as c, permutations as perm, product as p
from collections import deque
from copy import deepcopy
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 998244353
F = 1e-09

def si():
	return input()

def ii():
	return int(input())

def fi():
	return float(input())

def lstr():
	return input().split()

def lint():
	return list(map(int, input().split()))

def lintdec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [ii() for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]

def lcm(a, b):
	return a * b // math.gcd(a, b)
(N, K) = lint()
S = si()
J = {'R': 0, 'S': 1, 'P': 2}
dp = [[0] * 110 for _ in range(110)]

def winner(x, y):
	if (J[x] - J[y] + 3) % 3 == 1:
		return y
	return x

def tournament(m, n):
	if n == 0:
		dp[m][n] = S[m]
	if dp[m][n]:
		return dp[m][n]
	a = tournament(m, n - 1)
	b = tournament((m + pow(2, n - 1, N)) % N, n - 1)
	dp[m][n] = winner(a, b)
	return dp[m][n]

def main():
	print(tournament(0, K))

def __starting_point():
	main()
__starting_point()


def main(n, k, s):
	memo = dict()

	def junken(c_left, c_right):
		if c_left == 'R':
			if c_right == 'R':
				return 'R'
			elif c_right == 'P':
				return 'P'
			else:
				return 'R'
		elif c_left == 'P':
			if c_right == 'R':
				return 'P'
			elif c_right == 'P':
				return 'P'
			else:
				return 'S'
		elif c_right == 'R':
			return 'R'
		elif c_right == 'P':
			return 'S'
		else:
			return 'S'

	def f(left, left_idx, right, right_idx):
		if memo.get((left_idx, right_idx, right - left)) is not None:
			return memo[left_idx, right_idx, right - left]
		if right - left == 1:
			return s[left_idx]
		mid = left + (right - left) // 2
		res = junken(f(left, left_idx, mid, mid % n), f(mid, mid % n, right, right_idx))
		memo[left_idx, right_idx, right - left] = res
		return res
	print(f(0, 0 % n, 1 << k, (1 << k) % n))

def __starting_point():
	nk = [int(x) for x in input().split()]
	(n, k) = (nk[0], nk[1])
	s = input()
	main(n, k, s)
__starting_point()


def janken(sa, sb):
	if sa == 'R' and sb == 'S' or (sa == 'S' and sb == 'R'):
		return 'R'
	if sa == 'P' and sb == 'R' or (sa == 'R' and sb == 'P'):
		return 'P'
	if sa == 'S' and sb == 'P' or (sa == 'P' and sb == 'S'):
		return 'S'
	if sa == sb:
		return sa
(n, k) = list(map(int, input().split()))
s = input()
memo = [list(s)] + [[None] * n for _ in range(k)]
for i in range(1, k + 1):
	for j in range(n):
		sa = memo[i - 1][j]
		sb = memo[i - 1][(j + 2 ** (i - 1)) % n]
		memo[i][j] = janken(sa, sb)
print(memo[k][0])


import sys
readline = sys.stdin.readline
(N, K) = map(int, readline().split())
S = readline().rstrip()
S *= 2
N *= 2
WIN = {'RP': 'P', 'PR': 'P', 'PS': 'S', 'SP': 'S', 'SR': 'R', 'RS': 'R'}

def win(a, b):
	if a == b:
		return a
	return WIN[a + b]
for k in range(K):
	newS = ''
	for i in range(N // 2):
		newS += win(S[i * 2], S[i * 2 + 1])
	S = newS * 2
print(S[0])


(N, K) = map(int, input().split())
S = list(input())
hand = ['R', 'P', 'S']
for i in range(N):
	S[i] = hand.index(S[i])

def judge(A, B):
	(A, B) = (min(A, B), max(A, B))
	if A == 0 and B == 2:
		return A
	else:
		return B
cnt = K
while cnt:
	S += S
	T = []
	for i in range(0, len(S), 2):
		T.append(judge(S[i], S[i + 1]))
	S = T
	cnt -= 1
print(hand[S[0]])


(n, k) = map(int, input().split())
s = input()
(n, s) = (2 * n, 2 * s)
for _ in range(k):
	tmp = []
	for i in range(0, n, 2):
		if s[i] == s[i + 1]:
			tmp.append(s[i])
		else:
			comb = sorted([s[i], s[i + 1]])
			if comb == ['P', 'R']:
				tmp.append('P')
			elif comb == ['R', 'S']:
				tmp.append('R')
			else:
				tmp.append('S')
	s = ''.join(2 * tmp)
print(s[0])


import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

def input():
	return sys.stdin.readline()[:-1]

def ruiseki(lst):
	return [0] + list(accumulate(lst))

def celi(a, b):
	return -(-a // b)
sys.setrecursionlimit(5000000)
mod = pow(10, 9) + 7
al = [chr(ord('a') + i) for i in range(26)]
direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]
(n, k) = map(int, input().split())
s = list(input())

def check(a, b):
	if a == b:
		return 0
	elif a == 'R':
		if b == 'P':
			return 1
		else:
			return 0
	elif a == 'P':
		if b == 'S':
			return 1
		else:
			return 0
	elif b == 'R':
		return 1
	else:
		return 0
lst = s
for i in range(k):
	sanka = 2 ** (k - i)
	tmp = []
	if len(lst) % 2:
		lst = lst + lst
	m = min(len(lst), sanka)
	for j in range(m // 2):
		kk = check(lst[2 * j], lst[2 * j + 1])
		tmp.append(lst[2 * j + kk])
	lst = tmp[:]
print(lst[0])


from collections import defaultdict
(n, k) = list(map(int, input().split()))
s = input()
sL = []
for i in s:
	sL.append(i)
d = defaultdict(lambda : defaultdict(str))
(d['R']['S'], d['R']['R'], d['S']['R']) = ('R', 'R', 'R')
(d['P']['R'], d['P']['P'], d['R']['P']) = ('P', 'P', 'P')
(d['S']['P'], d['S']['S'], d['P']['S']) = ('S', 'S', 'S')
for _ in range(k):
	t = ''.join(sL + sL)
	for j in range(n):
		sL[j] = d[t[2 * j]][t[2 * j + 1]]
print(sL[0])


def comp(a, b):
	if a == 'R' and b == 'P':
		return b
	elif a == 'P' and b == 'S':
		return b
	elif a == 'S' and b == 'R':
		return b
	else:
		return a
(N, K) = map(int, input().split())
S = input()
T = S + S
dp = [[] for i in range(K + 1)]
for i in range(2 * N):
	dp[0].append(T[i])
for k in range(1, K + 1):
	for i in range(N):
		dp[k].append(comp(dp[k - 1][2 * i], dp[k - 1][2 * i + 1]))
	dp[k] = dp[k] + dp[k]
print(dp[K][0])


import sys
sys.setrecursionlimit(10 ** 6)
(N, K) = list(map(int, input().split()))
S = input()
S = S + S

def judge(a, b):
	if a == b:
		return a
	elif a == 'R':
		if b == 'S':
			return a
		else:
			return b
	elif a == 'P':
		if b == 'R':
			return a
		else:
			return b
	elif a == 'S':
		if b == 'R':
			return b
		else:
			return a
for k in range(K):
	N = len(S)
	T = ''
	for i in range(0, N, 2):
		T += judge(S[i], S[i + 1])
	S = T + T
print(S[0])


import sys

def input():
	return sys.stdin.readline().strip()

def mapint():
	return map(int, input().split())
sys.setrecursionlimit(10 ** 9)
(N, K) = mapint()
S = list(input())

def judge(ai, bi):
	(a, b) = (S[ai % N], S[bi % N])
	if a == b:
		return ai
	elif a == 'R' and b == 'S' or (a == 'P' and b == 'R') or (a == 'S' and b == 'P'):
		return ai
	else:
		return bi

def fight(lis):
	length = len(lis)
	ret = []
	for i in range(0, length, 2):
		ret.append(judge(lis[i], lis[i + 1]))
	return ret
cnt = N
goal = 2 ** K
old = list(range(N))
while cnt <= goal:
	new = fight(old * 2)
	cnt *= 2
	old = new
rem = old[:min(2 ** (N.bit_length() - 1), 2 ** K)]
while len(rem) != 1:
	rem = fight(rem)
print(S[rem[0]])


(n, k) = map(int, input().split())
s = list(input())
while k:
	t = s + s
	s = []
	for i in range(n):
		(a, b) = (t[i * 2], t[i * 2 + 1])
		if a == b:
			s.append(a)
		elif a == 'P' and b == 'R' or (a == 'R' and b == 'P'):
			s.append('P')
		elif a == 'P' and b == 'S' or (a == 'S' and b == 'P'):
			s.append('S')
		elif a == 'S' and b == 'R' or (a == 'R' and b == 'S'):
			s.append('R')
	k -= 1
print(s[0])


from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions, pprint
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
win = [('R', 'S'), ('S', 'P'), ('P', 'R')]

def ch(a, b):
	if a == b:
		return True
	if (a, b) in win:
		return True
	return False
(n, k) = inpl()
s = list(input())
for _ in range(k):
	s += s
	nx = []
	for i in range(2 * n)[::2]:
		if ch(s[i], s[i + 1]):
			nx.append(s[i])
		else:
			nx.append(s[i + 1])
	s = nx[:]
print(s[0])


from collections import defaultdict
(n, k) = list(map(int, input().split()))
s = input()
d = defaultdict(lambda : defaultdict(str))
(d['R']['R'], d['R']['S'], d['S']['R']) = ('R', 'R', 'R')
(d['P']['P'], d['P']['R'], d['R']['P']) = ('P', 'P', 'P')
(d['S']['S'], d['S']['P'], d['P']['S']) = ('S', 'S', 'S')
s2 = s + s
count = k
while count > 0:
	tmp = ''
	for i in range(0, len(s2), 2):
		tmp += d[s2[i]][s2[i + 1]]
	s2 = tmp + tmp
	count -= 1
print(s2[0])


(N, K) = list(map(int, input().split()))
S = list(input())
T = ['R', 'P', 'S']
for i in range(N):
	S[i] = T.index(S[i])
for _ in range(K):
	S += S
	tmp = []
	for i in range(0, len(S), 2):
		(a, b) = (S[i], S[i + 1])
		(a, b) = (max(a, b), min(a, b))
		if a == 2 and b == 0:
			x = b
		else:
			x = a
		tmp.append(x)
	S = tmp
print(T[S[0]])


def win(i, j):
	if i == j:
		return i
	if i == 'R' and j == 'P':
		return 'P'
	if i == 'P' and j == 'R':
		return 'P'
	if i == 'P' and j == 'S':
		return 'S'
	if i == 'S' and j == 'P':
		return 'S'
	if i == 'S' and j == 'R':
		return 'R'
	if i == 'R' and j == 'S':
		return 'R'

def step(S, k):
	T = S + S
	tmp = ''
	for i in range(len(S)):
		tmp += win(T[2 * i], T[2 * i + 1])
	return (tmp, k - 1)
(n, k) = list(map(int, input().split()))
s = input()
now = s
rem = k
while rem > 0:
	(now, rem) = step(now, rem)
print(now[0])


import sys
from functools import reduce
zz = 1
sys.setrecursionlimit(10 ** 5)
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def ii():
	return input().rstrip()

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def gtc(tc, ans):
	print(('Case #' + str(tc) + ':', ans))

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return list(map(int, input().split()))

def gh():
	sys.stdout.flush()

def isvalid(i, j, n, m):
	return 0 <= i < n and 0 <= j < m

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
uu = t
w = {'PS': 'S', 'PR': 'P', 'RS': 'R'}

def winner(s, p):
	if s == p:
		return s
	return w[''.join(sorted(s + p))]
dp = {}

def rec(i, j):
	if j == 0:
		dp[i, j] = s[i]
		return dp[i, j]
	if (i, j) in dp:
		return dp[i, j]
	dp[i, j] = winner(rec(i, j - 1), rec((i + pow(2, j - 1, n)) % n, j - 1))
	return dp[i, j]
while t > 0:
	t -= 1
	(n, k) = mi()
	s = ii()
	print(rec(0, k))


import numpy as np

def RPS(s1, s2):
	if s1 == s2:
		return s1
	elif set([s1, s2]) == set(['R', 'P']):
		return 'P'
	elif set([s1, s2]) == set(['P', 'S']):
		return 'S'
	elif set([s1, s2]) == set(['S', 'R']):
		return 'R'

def main():
	(N, K) = map(int, input().split())
	s = str(input())
	dp = [[0] * N for _ in range(K + 1)]
	for i in range(N):
		dp[0][i] = s[i]
	for k in range(1, K + 1):
		for i in range(N):
			dp[k][i] = RPS(dp[k - 1][2 * i % N], dp[k - 1][(2 * i + 1) % N])
	print(dp[K][0])

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
s = input()

def win(a, b):
	if a == b:
		return a
	return a if a + b in ['RS', 'SP', 'PR'] else b
shift = 1
for i in range(k):
	s1 = ''
	for j in range(n):
		(x, y) = (s[j], s[(j + shift) % n])
		s1 += win(x, y)
	s = s1
	shift = shift * 2 % n
print(s[0])


def solve(S):
	tbl = {80: {80: 80, 82: 80, 83: 83}, 82: {80: 80, 82: 82, 83: 82}, 83: {80: 83, 82: 82, 83: 83}}
	if len(S) % 2 == 1:
		S = S * 2
	S_ = []
	for i in range(int(len(S) / 2)):
		S_.append(tbl[S[i * 2]][S[i * 2 + 1]])
	return S_

def main():
	(N, K) = [int(x) for x in input().split()]
	S = [ord(x) for x in list(input())]
	for k in range(K):
		S = solve(S)
	print(chr(S[0]))
main()


def inputlist():
	return [int(j) for j in input().split()]
(n, k) = inputlist()
s = input()
s = s + s
n *= 2

def returnWinner(a, b):
	if a == b:
		return a
	else:
		if a + b == 'RS' or a + b == 'SR':
			return 'R'
		if a + b == 'RP' or a + b == 'PR':
			return 'P'
		if a + b == 'PS' or a + b == 'SP':
			return 'S'
if k == 1:
	ans = returnWinner(s[0], s[1])
	print(ans)
	return
from copy import deepcopy
for i in range(k - 1):
	s = s + s
	t = ['R'] * min(len(s) // 2, 2 ** (k - 1 - i))
	for j in range(0, min(len(s), 2 ** (k - i)), 2):
		t[j // 2] = returnWinner(s[j], s[j + 1])
	s = deepcopy(t)
	if len(s) == 1:
		print(s[0])
		return
print(s[0])


def resolve():
	(N, K) = map(int, input().split())
	S = input()

	def shorten(s):
		if len(s) % 2 == 1:
			s = s * 2
		ans = ''
		for i in range(0, len(s), 2):
			if s[i] == s[i + 1]:
				ans = ans + s[i]
			elif (s[i], s[i + 1]) == ('P', 'R') or (s[i], s[i + 1]) == ('R', 'P'):
				ans = ans + 'P'
			elif (s[i], s[i + 1]) == ('P', 'S') or (s[i], s[i + 1]) == ('S', 'P'):
				ans = ans + 'S'
			elif (s[i], s[i + 1]) == ('R', 'S') or (s[i], s[i + 1]) == ('S', 'R'):
				ans = ans + 'R'
		return ans
	ct = 0
	while ct < K:
		S = shorten(S)
		ct += 1
	print(S[0])
resolve()


(n, k) = map(int, input().split())
s = input()
s = s + s

def getVic(c):
	if c[0] == c[1]:
		return c[0]
	elif not 'R' in c:
		return 'S'
	elif not 'S' in c:
		return 'P'
	else:
		return 'R'
for i in range(k):
	s_ = ''
	for j in range(int(len(s) / 2)):
		s_ = s_ + getVic(s[j * 2:j * 2 + 2])
	s = s_ + s_
print(s[0])


(N, k) = map(int, input().split())
S = list(input())

def zyanken(a, b):
	if a == 'R':
		if b == 'P':
			return 'P'
		else:
			return 'R'
	elif a == 'S':
		if b == 'R':
			return 'R'
		else:
			return 'S'
	elif a == 'P':
		if b == 'S':
			return 'S'
		else:
			return 'P'
now = k
f = 0
dp = [['' for i in range(300)] for j in range(300)]
dp[0] = S
if N == 1:
	print(S[0])
else:
	for i in range(k):
		for j in range(N):
			dp[i + 1][j] = zyanken(dp[i][j * 2 % N], dp[i][(j * 2 + 1) % N])
	print(dp[k][0])


(n, k) = map(int, input().split())
s = input()

def f(h1, h2):
	if h1 == h2:
		return h1
	if h1 == 'P':
		if h2 == 'R':
			return 'P'
		else:
			return 'S'
	if h1 == 'R':
		if h2 == 'S':
			return 'R'
		else:
			return 'P'
	if h1 == 'S':
		if h2 == 'P':
			return 'S'
		else:
			return 'R'

def solve(hands, k):
	while k > 0:
		hands = nxt(hands)
		k -= 1
	print(hands[0])

def nxt(hands):
	hands += hands
	n_hand = []
	for i in range(len(hands) // 2):
		win = f(hands[2 * i], hands[2 * i + 1])
		n_hand.append(win)
	return n_hand
solve(s, k)


(N, K) = map(int, input().split())
S = input()
prev = [S[i % N] for i in range(2 * N)]
for i in range(K):
	res = []
	for j in range(N):
		if prev[j * 2] == 'R':
			if prev[j * 2 + 1] == 'R':
				res.append('R')
			elif prev[j * 2 + 1] == 'P':
				res.append('P')
			else:
				res.append('R')
		elif prev[j * 2] == 'P':
			if prev[j * 2 + 1] == 'R':
				res.append('P')
			elif prev[j * 2 + 1] == 'P':
				res.append('P')
			else:
				res.append('S')
		elif prev[j * 2 + 1] == 'R':
			res.append('R')
		elif prev[j * 2 + 1] == 'P':
			res.append('S')
		else:
			res.append('S')
	prev = res + res
print(res[0])


(n, k) = map(int, input().split())
s = input()
q = ''

def a_win(a, b):
	if a == 'S' and b == 'P':
		return True
	elif a == 'P' and b == 'R':
		return True
	elif a == 'R' and b == 'S':
		return True
	elif a == b:
		return True
	else:
		return False
for _ in range(k):
	if len(s) % 2 == 1:
		s = s * 2
	for i in range(0, len(s), 2):
		if a_win(s[i], s[i + 1]):
			q += s[i]
		else:
			q += s[i + 1]
	s = q
	q = ''
print(s[0])


(N, K) = list(map(int, input().split()))
S = input()
D = {'R': 0, 'P': 1, 'S': 2}

def winner(a, b):
	if (b - a) % 3 == 1:
		return b
	else:
		return a
L = [[0] * N for _ in range(K)]
A = [D[S[i]] for i in range(N)] * 2
for i in range(K):
	for j in range(N):
		L[i][j] = winner(A[2 * j], A[2 * j + 1])
	A = L[i] * 2
ans = L[-1][0]
if ans == 0:
	print('R')
elif ans == 1:
	print('P')
else:
	print('S')


(n, k) = list(map(int, input().split()))
s = list(input())

def f(a, b):
	p = set(['R', 'S'])
	q = set(['P', 'R'])
	r = set(['S', 'P'])
	if a == b:
		return a
	elif a in p and b in p:
		return 'R'
	elif a in q and b in q:
		return 'P'
	elif a in r and b in r:
		return 'S'
dp = [[0] * n for i in range(k + 1)]
for i in range(n):
	dp[0][i] = s[i]
for i in range(1, k + 1):
	for j in range(n):
		dp[i][j] = f(dp[i - 1][j], dp[i - 1][(j + pow(2, i - 1)) % n])
print(dp[k][0])


def winner(x, y):
	return x if x + y in ['RS', 'PR', 'SP'] else y

def f(level, offset):
	if (level, offset) in memo:
		return memo[level, offset]
	if level == 0:
		ret = s[offset]
	else:
		sub1 = f(level - 1, offset)
		sub2 = f(level - 1, (offset + 2 ** (level - 1)) % n)
		ret = winner(sub1, sub2)
	memo[level, offset] = ret
	return ret
(n, k) = list(map(int, input().split()))
s = input()
memo = {}
print(f(k, 0))


(N, K) = map(int, input().split())
S = input()
dp = [['?'] * (N + 1) for i in range(K + 1)]

def memo(k, i):
	if k == 0:
		return S[i]
	if dp[k][i] != '?':
		return dp[k][i]
	ni = (i + 2 ** (k - 1)) % N
	res = Win(memo(k - 1, i), memo(k - 1, ni))
	dp[k][i] = res
	return dp[k][i]

def Win(a, b):
	if a == 'R' and b == 'P':
		return b
	elif a == 'P' and b == 'S':
		return b
	elif a == 'S' and b == 'R':
		return b
	else:
		return a
ans = memo(K, 0)
print(ans)


ma = lambda : map(int, input().split())
lma = lambda : list(map(int, input().split()))
tma = lambda : tuple(map(int, input().split()))
ni = lambda : int(input())
yn = lambda fl: print('Yes') if fl else print('No')
ips = lambda : input().split()
import collections
import math
import itertools
import heapq as hq
import sys
ceil = math.ceil
gcd = math.gcd
RL = sys.stdin.readline
INF = 10 ** 15

def ceilab(a, b):
	return (a + b - 1) // b

def JK(s1, s2):
	if s1 == 'R':
		if s2 == 'P':
			return s2
		else:
			return s1
	elif s1 == 'S':
		if s2 == 'R':
			return s2
		else:
			return s1
	elif s1 == 'P':
		if s2 == 'S':
			return s2
		else:
			return s1
(N, K) = ma()
S = list(input())
S = S * 2
T = []
for k in range(K):
	T = []
	for i in range(N):
		T.append(JK(S[2 * i], S[2 * i + 1]))
	S = T * 2
print(T[0])


import bisect, collections, copy, functools, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7

def I():
	return int(input())

def F():
	return float(input())

def SS():
	return input()

def LI():
	return [int(x) for x in input().split()]

def LI_():
	return [int(x) - 1 for x in input().split()]

def LF():
	return [float(x) for x in input().split()]

def LSS():
	return input().split()

def resolve():
	(n, k) = LI()
	s = SS()
	s = s * 2
	d = {'R': 0, 'P': 1, 'S': 2}
	d_r = {0: 'R', 1: 'P', 2: 'S'}
	dp = [[-1] * n for _ in range(k + 1)]

	def f(k, i):
		if dp[k][i] == -1:
			if k == 0:
				dp[k][i] = d[s[i]]
			else:
				l = f(k - 1, i)
				r = f(k - 1, (i + pow(2, k - 1, n)) % n)
				if l == r or (l - r) % 3 == 1:
					dp[k][i] = l
				else:
					dp[k][i] = r
		return dp[k][i]
	f(k, 0)
	print(d_r[dp[k][0]])

def __starting_point():
	resolve()
__starting_point()


(n, k) = list(map(int, input().split()))
s = input()
W = [[0, 1, 0], [1, 1, 2], [0, 2, 2]]
B = [[0] * n for _ in range(2)]
J = 'RPS'
for j in range(n):
	B[0][j] = 0 if s[j] == 'R' else 1 if s[j] == 'P' else 2
for i in range(k):
	for j in range(n):
		B[-~i % 2][j] = W[B[i % 2][j]][B[i % 2][(j + 2 ** i) % n]]
print(J[B[k % 2][0]])


from typing import List

def winner(a: str, b: str) -> str:
	return b if (a, b) in [('R', 'P'), ('P', 'S'), ('S', 'R')] else a

def rec(k, offset):
	if k == 0:
		return S[offset]
	elif memo[k][offset] != '?':
		return memo[k][offset]
	former = rec(k - 1, offset)
	latter = rec(k - 1, (offset + p2[k - 1]) % N)
	memo[k][offset] = winner(former, latter)
	return memo[k][offset]
(N, K) = list(map(int, input().split()))
S: List[str] = list(input())
p2 = [1]
for k in range(K):
	p2.append(p2[-1] * 2 % N)
memo = [['?'] * (N + 1) for _ in range(K + 1)]
rec(K, 0)
print(memo[K][0])


(n, k) = list(map(int, input().split()))
s = list(input()[::-1]) * 2
ptn = ['PR', 'RS', 'SP', 'RP', 'SR', 'PS', 'PP', 'RR', 'SS']
for _ in range(k):
	tmp = []
	while s:
		win = ptn.index(s.pop() + s.pop()) % 3
		tmp.append(['P', 'R', 'S'][win])
	s = tmp[::-1] * 2
print(s.pop())


(N, K) = [int(_) for _ in input().split()]
S = list(input())
g = {}
g['R', 'R'] = 'R'
g['R', 'P'] = 'P'
g['R', 'S'] = 'R'
g['P', 'R'] = 'P'
g['P', 'P'] = 'P'
g['P', 'S'] = 'S'
g['S', 'R'] = 'R'
g['S', 'P'] = 'S'
g['S', 'S'] = 'S'
for _ in range(K):
	S *= 2
	S = [g[a, b] for (a, b) in zip(S[::2], S[1::2])]
print(S[0])


def win(a, b):
	if a == 'R':
		if b == 'P':
			return 'P'
		else:
			return 'R'
	if a == 'S':
		if b == 'R':
			return 'R'
		else:
			return 'S'
	if a == 'P':
		if b == 'S':
			return 'S'
		else:
			return 'P'
	assert False
(n, k) = list(map(int, input().split()))
s = list(input())
for _ in range(k):
	t = s * 2
	for i in range(n):
		s[i] = win(t[i * 2], t[i * 2 + 1])
print(s[0])


def main():
	import sys
	import time
	input = sys.stdin.readline
	(N, K) = [int(x) for x in input().strip().split()]
	S = list(input().strip())
	janken = {('R', 'R'): 'R', ('R', 'S'): 'R', ('R', 'P'): 'P', ('S', 'R'): 'R', ('S', 'S'): 'S', ('S', 'P'): 'S', ('P', 'R'): 'P', ('P', 'S'): 'S', ('P', 'P'): 'P'}
	memo = {}

	def dp(k, p):
		if (k, p) in memo:
			return memo[k, p]
		if k == 1:
			return janken[S[p % N], S[(p + 1) % N]]
		memo[k, p] = janken[dp(k - 1, p * 2 % N), dp(k - 1, (p + 1) * 2 % N)]
		return memo[k, p]
	print(dp(K, 0))

def __starting_point():
	main()
__starting_point()


def main():
	(text_len, k) = [int(x) for x in input().split()]
	text = input()
	text *= 2
	for _ in range(k):
		new_text = ''
		for i in range(0, text_len):
			new_text += janken(text[i * 2], text[i * 2 + 1])
		text = new_text * 2
	return text[0]

def janken(a, b):
	if a == b:
		return a
	if 'P' not in (a, b):
		return 'R'
	if 'S' not in (a, b):
		return 'P'
	if 'R' not in (a, b):
		return 'S'

def __starting_point():
	print(main())
__starting_point()


def janken(h1, h2):
	handdet = (h2 - h1) % 3
	if handdet == 1:
		return h2
	else:
		return h1

def jankenOnce(handls):
	wonhand = []
	L = len(handls)
	for pair in range(L // 2):
		wonhand.append(janken(handls[2 * pair], handls[2 * pair + 1]))
	return wonhand

def getWinner(handls):
	if len(handls) % 2 == 1:
		return handls
	else:
		winnersList = jankenOnce(handls)
		return getWinner(winnersList)
(n, k) = [int(hoge) for hoge in input().split()]
S = input()
hands = []
for s in S:
	if s == 'R':
		hands.append(0)
	elif s == 'P':
		hands.append(1)
	elif s == 'S':
		hands.append(2)
if n % 2:
	n *= 2
	hands = hands + hands
newhands = hands
for i in range(k):
	newhands = jankenOnce(newhands)
	newhands += newhands
JK = ['R', 'P', 'S']
print(JK[newhands[0]])


def winner(a, b):
	battle = {a, b}
	if battle == {'R', 'S'}:
		return 'R'
	elif battle == {'R', 'P'}:
		return 'P'
	elif battle == {'P', 'S'}:
		return 'S'
	return a
(n, k) = list(map(int, input().split()))
S = input()
dp = [[''] * n for _ in range(k + 1)]
for i in range(n):
	dp[0][i] = S[i]

def solve(k, i):
	if dp[k][i] == '':
		dp[k][i] = winner(solve(k - 1, i), solve(k - 1, (i + 2 ** (k - 1)) % n))
	return dp[k][i]
print(solve(k, 0))


def junken(c_left, c_right):
	if c_left == 'R':
		if c_right == 'R':
			return 'R'
		elif c_right == 'P':
			return 'P'
		else:
			return 'R'
	elif c_left == 'P':
		if c_right == 'R':
			return 'P'
		elif c_right == 'P':
			return 'P'
		else:
			return 'S'
	elif c_right == 'R':
		return 'R'
	elif c_right == 'P':
		return 'S'
	else:
		return 'S'

def main(n, k, s):
	prev_s = s
	new_s = []
	for _ in range(0, k):
		t = prev_s + prev_s
		for i in range(0, n):
			new_s.append(junken(t[i * 2], t[i * 2 + 1]))
		prev_s = new_s
		new_s = []
	print(prev_s[0])

def __starting_point():
	(n, k) = [int(x) for x in input().split()]
	s = input()
	main(n, k, s)
__starting_point()


(n, k) = map(int, input().split())
S = input()
L = ['RPS'.find(s) for s in S]

def winner(a, b):
	if (b - a) % 3 == 1:
		return b
	return a
for _ in range(k):
	if len(L) % 2:
		L += L
	L = [winner(L[2 * i], L[2 * i + 1]) for i in range(len(L) // 2)]
print('RPS'[L[0]])


from copy import copy
(n, k) = map(int, input().split())
s = list(input())
if n % 2 != 0:
	s.extend(s)
for i in range(k):
	t = [0] * (len(s) // 2)
	for i in range(len(s) // 2):
		if s[i * 2] == s[i * 2 + 1]:
			t[i] = s[i * 2]
		elif s[i * 2] == 'R' and s[i * 2 + 1] == 'P' or (s[i * 2] == 'P' and s[i * 2 + 1] == 'S') or (s[i * 2] == 'S' and s[i * 2 + 1] == 'R'):
			t[i] = s[i * 2 + 1]
		else:
			t[i] = s[i * 2]
	if len(t) % 2 != 0:
		t.extend(t)
	s = copy(t)
print(t[0])


(n, k) = map(int, input().split())
s = input()
power = [1]
for i in range(k):
	power.append(power[-1] * 2 % n)
dp = list(s)
for j in range(k):
	ndp = [None] * n
	for i in range(n):
		a = dp[i]
		b = dp[(i + power[j]) % n]
		if a == 'R':
			ndp[i] = a if b == 'S' else b
		elif a == 'P':
			ndp[i] = a if b == 'R' else b
		else:
			ndp[i] = a if b == 'P' else b
	dp = ndp
print(dp[0])


win = {'R': 'P', 'P': 'S', 'S': 'R'}
(n, k) = list(map(int, input().split()))
dp = [[c for c in input()]]
for i in range(k):
	dp.append([*dp[i]])
	for j in range(n):
		a = dp[i][j * 2 % n]
		b = dp[i][(j * 2 + 1) % n]
		dp[i + 1][j] = b if win[a] == b else a
print(dp[k][0])


from sys import stdin, setrecursionlimit
import bisect, collections, copy, heapq, itertools, math, string
setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 1000000007

def input():
	return stdin.readline().strip()

def main():
	(n, k) = list(map(int, input().split()))
	s = input()
	dp = [['' for _ in range(105)] for _ in range(105)]
	for i in range(n):
		dp[0][i] = s[i]
	for i in range(1, k + 1):
		for j in range(n):
			a = dp[i - 1][j]
			b = dp[i - 1][(j + pow(2, i - 1)) % n]
			st = {a, b}
			rec = ''
			if st == set('RS'):
				rec = 'R'
			elif st == set('SP'):
				rec = 'S'
			elif st == set('PR'):
				rec = 'P'
			else:
				rec = a
			dp[i][j] = rec
	ans = dp[k][0]
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
s = [i for i in input()]

def jk(a, b):
	if a == 'R':
		if b == 'P':
			return b
		else:
			return a
	elif a == 'P':
		if b == 'S':
			return b
		else:
			return a
	elif b == 'R':
		return b
	else:
		return a
while k:
	t = s + s
	for i in range(n):
		s[i] = jk(t[i * 2], t[i * 2 + 1])
	k -= 1
print(s[0])