#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 1100000;

int n, ch[N][3], to[3], ind[N], pw[15], tot, root, ans[N];
char s[N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

void build(int &k, int dep, int x) {
	k = ++tot;
	if (dep == n) {
		ind[k] = x;
		return;
	}
	for (R int i = 0; i <= 2; ++i)
		build(ch[k][i], dep + 1, x + i * pw[dep]);
	return;
}

void modify(int k, int dep) {
	if (dep == n) return;
	modify(ch[k][to[2]], dep + 1);
	int tmp = ch[k][to[0]];
	ch[k][to[0]] = ch[k][to[2]], ch[k][to[2]] = ch[k][to[1]], ch[k][to[1]] = tmp;
	return;
}

void dfs(int k, int dep, int x) {
	if (dep == n) {
		ans[ind[k]] = x;
		return;
	}
	for (R int i = 0; i <= 2; ++i)
		dfs(ch[k][to[i]], dep + 1, x + i * pw[dep]);
	return;
}

int main() {
	read(n), scanf("%s", s + 1);
	pw[0] = 1, to[1] = 1, to[2] = 2;
	for (R int i = 1; i <= n; ++i) pw[i] = pw[i - 1] * 3;
	build(root, 0, 0);
	for (R int i = 1, m = strlen(s + 1); i <= m; ++i) {
		if (s[i] == 'S')
			swap(to[1], to[2]);
		else
			modify(root, 0);
	}
	dfs(root, 0, 0);
	for (R int i = 0; i < pw[n]; ++i)
		cout << ans[i] << ' ';
	return 0;
}