#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#define rep(i,n) for (int i=0;i<n;i++)

#define DENOM 1000000007

using namespace std;
using ll = long long;

char win_rps(char a, char b) {
  if (a==b) {
    return a ;
  }
  if ((a=='R' && b=='S') || (a=='S' && b=='R')) {
    return 'R' ;
  } else if ((a=='S' && b=='P') || (a=='P' && b=='S')) {
    return 'S' ;
  } else {
    return 'P' ;
  }
}

int main(){
  int n, k ;
  string prev_s, s;
  size_t s_length;
  cin >> n >> k ;
  cin >> prev_s;
  for (int i = 0 ; i< k ; ++i) {
    prev_s += prev_s ;
    s_length = prev_s.size() ;
    if (s_length == 1) {
      cout << prev_s[0] << endl ;
      return 0 ;
    }
    s = "" ;
    for (int j = 0 ; j < s_length ; j+=2) {
      s += win_rps(prev_s[j], prev_s[j+1]) ;
    }
    prev_s = s ;
    cerr << i << ": " << prev_s << endl ;    
  }
  cout << prev_s[0] << endl ;
  return 0 ;
}

#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i,j,n) for(long long i = j ; i < n ; ++i)
#define fr(i,n,j) for(long long i = n ; i >= j ; --i)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long>> vpll;
const ll N = 2e5 + 100;
const ll M = 1e6 + 100;
const ll mod =  998244353;
const ll inf = 1e17 +100;
ll n,a[N],dp[N],ct = 0;

ll mul(ll a,ll b){
	return (a*b)%mod;
}

ll sum(ll a,ll b){
	return (a+b)%mod;
}

ll res(ll a,ll b){
	ll x = (a-b)%mod;
	if(x >= 0) return x;
	return (x+2*mod)%mod;
}

void solve(){
	cin >> n;
	f(i,1,n+1) cin >> a[i];
	sort(a+1,a+n+1);
	dp[0] = 0;
	f(i,1,n+1){
		ct = sum(ct,a[i]);
		dp[i] = sum(dp[i-1],mul(ct,a[i]));
		// cout << ct << " " << a[i] << endl;
		ct = res(ct,a[i]);
		// cout << ct << " " << 0 << endl;
		ct = mul(2,ct);
		ct = sum(ct,a[i]);
		// cout << ct << endl;
	}
	cout << dp[n] << endl;
}
 
int main(){
	fastio;
	ll tc = 1;
	// cin >> tc;
	while(tc--) solve();
	return 0;
}