#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 535005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

char s[MAXN];
int n, m, mx, ans[MAXN];
int root, tot, ch[MAXN * 13][3], ori[MAXN * 13], tag[MAXN * 13];

void pushdown(int rt) {
	if (tag[rt]) {
		swap(ch[rt][1], ch[rt][2]);
		for (int i = 0; i < 3; ++i) {
			tag[ch[rt][i]] ^= 1;
		}
		tag[rt] = 0;
	}
}

void Build(int &rt, int dep, int w, int num) {
	rt = ++tot;
	if (dep == n) {
		ori[rt] = num;
		return;
	}
	for (int i = 0; i < 3; ++i) {
		Build(ch[rt][i], dep + 1, w * 3, num + w * i);
	}
}

void Add1() {
	int rt = root;
	for (int i = 0; i < n; ++i) {
		pushdown(rt);
		swap(ch[rt][0], ch[rt][1]);
		swap(ch[rt][0], ch[rt][2]);
		rt = ch[rt][0];
	}
}

void GetAns(int rt, int dep, int w, int num) {
	if (dep == n) {
		ans[ori[rt]] = num;
		return;
	}
	pushdown(rt);
	for (int i = 0; i < 3; ++i) {
		GetAns(ch[rt][i], dep + 1, w * 3, num + w * i);
	}
}

void init() {
	read(n);
	scanf("%s", s + 1);
	m = strlen(s + 1);
	for (int i = mx = 1; i <= n; ++i, mx *= 3);
}

void solve() {
	Build(root, 0, 1, 0);
	for (int i = 1; i <= m; ++i) {
		if (s[i] == 'S') {
			tag[root] ^= 1;
		} else {
			Add1();	
		}/*
		GetAns(root, 0, 1, 0);
		for (int i = 0; i < mx; ++i) {
			printf("%d ", ans[i]);
		}
		printf("\n");*/
	}
	GetAns(root, 0, 1, 0);
	for (int i = 0; i < mx; ++i) {
		printf("%d ", ans[i]);
	}
}

int main() {
	init();
	solve();
	return 0;
}
