#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int L = 13;
const int N = 1e6;

int l;
int q;
string t;
int pw[L];
int n;
int per[N];
int lst[N];
int dig[N];
int was[N];
int cnt = 0;

void push(int i) {
	if (dig[i] && (was[i] - cnt) % 2) {
		dig[i] = 3 - dig[i];
	}
	was[i] = cnt;
}

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	pw[0] = 1;
	for (int i = 1; i < L; ++i) {
		pw[i] = pw[i - 1] * 3;
	}
	cin >> l >> t;
	n = pw[l];
	q = (int)t.size();
	for (int lvl = 0; lvl < l; ++lvl) {
		int len = pw[lvl];
		for (int i = 0; i < len; ++i) {
			per[i + 2 * len] = per[i + len] = per[i];
			dig[i] = 0;
			was[i] = 0;
			dig[i + len] = 1;
			was[i + len] = 0;
			dig[i + 2 * len] = 2;
			was[i + 2 * len] = 0;
		}
		cnt = 0;
		for (int ind = 0; ind < q; ++ind) {
			int pos = lst[ind];
			int tmp = -1;
			for (; pos < 3 * len; pos += len) {
				push(pos);
				if (dig[pos] == 2) {
					tmp = pos;
				}
			}
			assert(tmp != -1);
			if (t[ind] == 'S') {
				++cnt;
			} else {
				pos = lst[ind];
				push(pos);
				push(pos + len);
				push(pos + 2 * len);
				(++dig[pos]) %= 3;
				(++dig[pos + len]) %= 3;
				(++dig[pos + 2 * len]) %= 3;
			}
			lst[ind] = tmp;
		}
		for (int i = 0; i < 3 * len; ++i) {
			push(i);
			per[i] += dig[i] * pw[lvl];
		}
	}
	for (int i = 0; i < pw[l]; ++i) {
		cout << per[i] << " ";
	}
	cout << endl;
	return 0;
}
