//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 2000005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
const int S = 10000005;
int nx[S][3];
int tr[S];
int rt = 1;
int idcnt = 2;
int tp[S];
void down(int k) {
	if (tp[k]) {
		swap(nx[k][1], nx[k][2]);
		for (int j = 0; j < 3; j++)
			tp[nx[k][j]] ^= 1;
		tp[k] = 0;
	}
}
void pl(int k) {
	if (tr[k] != -1) return ;
	down(k);
	int r[3] = {nx[k][0], nx[k][1], nx[k][2]};
	for (int j = 0; j < 3; j++)
		nx[k][j] = r[(j + 2) % 3];
	pl(nx[k][0]);
}
int pw[maxn];
char u[maxn];
int mr[maxn], p[maxn];
int main() {
	int n;
	cin >> n;
	pw[0] = 1;
	for (int i = 1; i <= n; i++)
		pw[i] = pw[i - 1] * 3;
	memset(tr, -1, sizeof(tr));
	for (int i = 0; i < pw[n]; i++) {
		int pl = rt, cur = i;
		for (int j = 0; j < n; j++) {
			int ne = cur % 3;
			cur /= 3;
			if (!nx[pl][ne]) nx[pl][ne] = idcnt++;
			pl = nx[pl][ne];
		}
		tr[pl] = i;
	}
//	cout << idcnt << endl;
	scanf("%s", u);
	int l = strlen(u);
	for (int j = 0; j < l; j++) {
		if (u[j] == 'S') tp[rt] ^= 1;
		else 
			pl(rt);
	}
	for (int i = 0; i < pw[n]; i++) {
		int pl = rt, cur = i;
		for (int j = 0; j < n; j++) {
			int ne = cur % 3; cur /= 3;
			down(pl);
			pl = nx[pl][ne];
		}
		mr[i] = tr[pl];
		p[mr[i]] = i;
	}
	for (int j = 0; j < pw[n]; j++)
		printf("%d ", p[j]);
	return 0;
}
