#include <bits/stdc++.h>

using namespace std;

#define MS(a, b) memset(a, b, sizeof(a))
#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define EREP(a, b) for (register int a = head[b]; a; a = edge[a].nxt)

inline int rd() {
    int x = 0; char c = getchar(); bool f = 0;
    while (c < '0' && c != '-') c = getchar();
    if (c == '-') f = 1, c = getchar();
    while (c >= '0') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    return f ? -x : x;
}

const int SIZE = 2e5 + 100;

int n; 

int head[SIZE], ecnt;
struct Edge {
	int v, nxt;
} edge[SIZE << 1];
void Add_Edge (int u, int v) {
	edge[++ecnt] = (Edge) { v, head[u] };
	head[u] = ecnt;
}

int dep[SIZE], F[SIZE];
int mx[SIZE][2];
int Len = -1, A, B;
void dfs (int u, int fa) {
	F[u] = fa;
	dep[u] = dep[fa] + 1;
	mx[u][0] = mx[u][1] = u;
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		dfs(v, u);
		if (dep[mx[v][0]] > dep[mx[u][0]])
			mx[u][1] = mx[u][0], mx[u][0] = mx[v][0];
		else if (dep[mx[v][0]] > dep[mx[u][1]])
			mx[u][1] = mx[v][0];
	}
	if (dep[mx[u][0]] + dep[mx[u][1]] - 2 * dep[u] > Len) {
		Len = dep[mx[u][0]] + dep[mx[u][1]] - 2 * dep[u];
		A = mx[u][0];
		B = mx[u][1];
	}
}
bool mark[SIZE];
int E;
int ans[SIZE];
void D (int u, int fa) {
	++E;
	ans[u] = E;
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		if (!mark[v]) D(v, u);
	}
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		if (mark[v]) D(v, u);
	}
	++E;
}

void _main () {
	n = rd();
	FOR (i, 1, n) {
		int u = rd(), v = rd();
		Add_Edge(u, v);
		Add_Edge(v, u);
	}
	dfs(1, 0);
	int T = A;
	while (A != B) {
		if (dep[A] < dep[B]) swap(A, B);
		mark[A] = 1;
		A = F[A];
	} mark[A] = 1;
	D(T, 0);
	REP (i, 1, n) printf ("%d ", ans[i]);
}

int main () {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	_main();
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;

const int MAXN = 123;
int dp[MAXN][MAXN];
char s[MAXN];
int ds[MAXN];
int pw2[MAXN];

int vs(int a, int b) {
    if (a == 1) {
        return b != 2;
    } else if (a == 2) {
        return b != 3;
    }
    return b != 1;
}

int dfs(int n, int S, int N) {
    if (dp[n][S]) return dp[n][S];
    if (S == 1) {
        int a = ds[(n % N) + 1], b = ds[((n + 1) % N) + 1];
        return dp[n][S] = (vs(a, b) ? a : b);
    }
    int l = dfs(n, S - 1, N), r = dfs((n + pw2[S - 1]) % N, S - 1, N);
    return dp[n][S] = (vs(l, r) ? l : r);
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    scanf("%s", s + 1);
    for (int i = 1; i <= N; i++) {
        if (s[i] == 'R') ds[i] = 1;
        else if (s[i] == 'P') ds[i] = 2;
        else ds[i] = 3;
    }
    pw2[0] = (1 % N);
    for (int i = 1; i <= N; i++)
        pw2[i] = (pw2[i - 1] * 2) % N;
    char V[] = {0, 'R', 'P', 'S'};
    printf("%c\n", V[dfs(0, K, N)]);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/
