#include <bits/stdc++.h>
using namespace std;

pair<int,int> jmp[13][210000][3];
pair<int,int> jmp2[13][210000][3];
int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int N;
	cin >> N;
	string s;
	cin >> s;
	int n = (int)s.size();
	vector<int> rsum(n+1, 0), ssum(n+1);
	for(int i = 0; i < n; i++){
		rsum[i+1] = rsum[i] + (s[i] == 'R');
		ssum[i+1] = ssum[i] + (s[i] == 'S');
	}
	for(int j = 0; j <= N; j++){
		for(int i = n; i >= 0; i--){
			for(int r = 0; r < 3; r++){
				jmp[j][i][r] = {n+1, 0};
				jmp2[j][i][r] = {i, r};
			}
		}
	}
	for(int i = n-1; i >= 0; i--){
		for(int r = 0; r < 3; r++){
			int nxt = (s[i] == 'S' ? (3 - r) % 3 : (r + 1) % 3);
			jmp[0][i][r] = {i+1, nxt};
			if(r == 2 && s[i] == 'R'){
				jmp2[0][i][r] = {i, r};
			} else {
				jmp2[0][i][r] = jmp2[0][i+1][nxt];
			}
		}
	}
	for(int j = 1; j <= N; j++){
		vector<vector<int> > work(n+1, vector<int>(3, n+1));
		for(int i = n; i >= 0; i--){
			// when reach j 0s
			for(int r = 0; r < 3; r++){
				pair<int,int> res = jmp[j-1][i][r];
				if(res.first == n + 1){
					work[i][r] = n + 1;
				} else if(res.second == 0){
					work[i][r] = res.first;
				} else {
					work[i][r] = work[res.first][res.second];
				}
			}
		}
		for(int i = n; i >= 0; i--){
			for(int r = 0; r < 3; r++){
				int f = work[i][0];
				if(f == n+1){
					jmp[j][i][r] = {n+1, 0};
					jmp2[j][i][r] = {i, r};
				} else {
					if(f == i+1){
						assert(s[i] == 'S');
						jmp[j][i][r] = {f, (3 - r) % 3};
						jmp2[j][i][r] = jmp2[j][f][(3 - r) % 3];
					} else {
						assert(s[i] == 'R');
						assert(s[f-1] == 'R');
						int ns = ssum[f] - ssum[i];
						int end = ((ns & 1) ? (3 - r) : (r)) % 3;
						jmp[j][i][r] = {f, (end + 1) % 3};
						if(end == 2 && j < N){
							jmp2[j][i][r] = {i, r};
						} else {
							jmp2[j][i][r] = jmp2[j][f][(end + 1) % 3];
						}
					}
				}
				assert(jmp2[j][i][r].first >= i);
			}
		}
	}
	int cn = 1;
	for(int i = 0; i < N; i++) cn *= 3;
	for(int st = 0; st < cn; st++){
		int cst = st;
		vector<int> val(N);
		for(int j = 0; j < N; j++){
			val[j] = cst % 3;
			cst /= 3;
		}
		assert(cst == 0);
		int cur = 0;
		for(int j = 0; j < N; j++){
			if(val[j] == 0) continue;
			{
				pair<int,int> f = jmp2[j][cur][val[j]];
				int ns = ssum[f.first] - ssum[cur];
				if(ns & 1) for(int& a : val) a = (3 - a) % 3;
				cur = f.first;
				val[j] = f.second;
			}
			{
				pair<int,int> f = jmp[j][cur][val[j]];
				if(f.first == n+1) continue;
				assert(f.second == 0);
				int ns = ssum[f.first] - ssum[cur];
				if(ns & 1) for(int& a : val) a = (3 - a) % 3;
				assert(val[j] == 2);
				val[j] = 3;
				for(int r = j; r < N; r++){
					if(val[r] == 3){
						val[r] = 0;
						if(r + 1 < N){
							val[r+1]++;
						}
					}
				}
				cur = f.first;
			}
		}
		for(int j = N; j >= 0; j--){
			bool allzero = true;
			for(int i = 0; i < j; i++) if(val[i] != 0) allzero = false;
			if(!allzero) continue;
			pair<int,int> f = jmp2[j][cur][(j == N) ? 0 : val[j]];
			int ns = ssum[f.first] - ssum[cur];
			if(ns & 1) for(int& a : val) a = (3 - a) % 3;
			cur = f.first;
			if(j < N) val[j] = f.second;
		}
		int ans = 0;
		for(int i = N-1; i >= 0; i--){
			ans = (3 * ans) + val[i];
		}
		assert(cur == n);
		cout << ans << ' ';
	}
	cout << '\n';
}

Measured memory_bytes: 137956