#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

using namespace std;

ll power(ll n, ll k, ll mod){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % mod;
    n = n * n % mod;
    k >>= 1;
  }
  return res;
}



ll tf(char c){
  switch (c) {
    case 'R' : return 0;
    case 'P' : return 1;
    case 'S' : return 2;
  }
}
char inv(ll a){
  switch (a) {
    case 0 : return 'R';
    case 1 : return 'P';
    case 2 : return 'S';
  }
}

int main(void){
  ll n, k;
  cin >> n >> k;
  string t;
  cin >> t;
  vector<ll> s(n);
  for (ll i = 0; i < n; i++){
    s[i] = tf(t[i]);
  }


  vector<vector<ll>> memo(n, vector<ll>(k+1, -1));
  function<ll(ll, ll)> rec = [&](ll a, ll j){
    if (memo[a][j] != -1)
      return memo[a][j];
    if (j == 0){
      memo[a][j] = s[a];
      return memo[a][j];
    }

    ll x = rec(a, j-1);
    ll y = rec((a + power(2, j-1, n)) % n, j-1);
    if ((x + 1) % 3 == y)
      memo[a][j] = y;
    else
      memo[a][j] = x;

    return memo[a][j];
  };

  cout << inv(rec(0, k)) << endl;


  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define rep(i,n) for(int i=0;i<(n);i++)
#define drep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    bool operator==(const mint a)const{
        return x==a.x;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N);
    rep(i,N) cin >> A[i];
    sort(all(A));
    mint ans = 0;
    mint val = 0;
    vec<mint> p2(N+1,1);
    rep(i,N) p2[i+1] = p2[i]*2;
    for(int i=1;i<N;i++) val += p2[i-1]*A[i];
    rep(i,N){
        ans += (val+A[i])*A[i];
        if(i+1!=N){
            val -= A[i+1];
            val /= 2;
        }
    }
    cout << ans << "\n";
}