#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

/*
N = 1

0
1
2

N = 2

00
01
02
10
11 - (time=5, time=8) > 21
12
20
21 = 3^1 * 1 + 3^0 * 2     x/3
22

N = 3

020 -> ?11

salsa flips 1's and 2's

SSSRRRSSRSRRSSRRSSSRRSR
        ^      ^
        
        O(overflows)
        
        
0
1
2
3
4
5
6
7
8
9
10

e
0
1
2
00
01
02
10
11
12
20
21
22
000
001
002
*/        
        
const int nax = 540123;
char s[nax];
vector<int> moments_of_change[13][nax];
int perm[13][nax];

int n;
int reverse_trits(int mask) {
	int real_value = 0;
	for(int i = 0; i < n; ++i) {
		real_value = 3 * real_value + mask % 3;
		mask /= 3;
	}
	return real_value;
}

int main() {
	scanf("%d", &n);
	scanf("%s", s);
	int S = strlen(s);
	int my_power = 1;
	
	for(int i = 0; i < S; ++i) {
		if(s[i] == 'R') {
			moments_of_change[0][0].push_back(i);
		}
	}
	
	vector<int> pref(S + 1);
	for(int i = 1; i <= S; ++i) {
		pref[i] = pref[i-1] + (s[i-1] == 'S');
	}
	
	for(int mask_len = 1; mask_len <= n; ++mask_len) {
		my_power *= 3;
		for(int mask = 0; mask < my_power; ++mask) {
			int parent = mask / 3;
			int digit = mask % 3;
			int prv = -1;
			// int memo_digit = digit;
			
			for(vector<int> tmp : {moments_of_change[mask_len-1][parent], {S}}) {
				for(int now : tmp) {
					int salsas = pref[now] - pref[prv+1];
					// for(int i = prv + 1; i < now; ++i) {
						// if(s[i] == 'S') {
							// salsas++;
						// }
					// }
					if(salsas % 2) {
						if(digit == 1) {
							digit = 2;
						}
						else if(digit == 2) {
							digit = 1;
						}
					}
					if(now != S) {
						digit++;
						if(digit == 3) {
							digit = 0;
							moments_of_change[mask_len][mask].push_back(now);
						}
					}
					prv = now;
				}
			}
			// debug() << imie(mask) imie(memo_digit) imie(digit);
			
			perm[mask_len][mask] = perm[mask_len-1][parent] * 3 + digit;
		}
	}
	vector<int> answer(my_power);
	for(int mask = 0; mask < my_power; ++mask) {
		// answer[reverse_trits(mask)]
		// int cur = mask;
		// int real_value = 0;
		// for(int rep = 0; rep < n; ++rep) {
			// real_value = 3 * real_value + cur % 3;
			// cur /= 3;
		// }
		printf("%d ", reverse_trits(perm[n][reverse_trits(mask)]));
		// debug() << imie(mask) imie();
		// debug() << imie(mask) imie(perm[n][mask]);
	}
	puts("");
	
	/*
	vector<int> moments_of_change[3**n];
	vector<pair<int,int>> overflows; // (when, which_number)
	// path_of[0]
	for(int trit = 0; trit < N; ++trit) {
		
	}*/
}


Measured memory_bytes: 199648