#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int N = 540000;

int n;
string s;
int l;
int r;
int pl, pr;
int p[N];
int rr[N];
int al[N];
int ar[N];

int get(int x) {
	int ans = 0;
	int now = 1;
	while (x) {
		int c = x % 3;
		x /= 3;
		if (c == 1) {
			ans += now * 2;
		} else if (c == 2) {
			ans += now;
		}
		now *= 3;
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n;
	cin >> s;
	r = n / 2;
	l = n - r;
	pl = 1;
	for (int i = 0; i < l; ++i) {
		pl *= 3;
	}
	pr = 1;
	for (int i = 0; i < r; ++i) {
		pr *= 3;
	}

	for (int i = 0; i < pl * pr; ++i) {
		rr[i] = get(i);
	}

	for (int i = 0; i < pr; ++i) {
		p[i] = i;
	}

	for (int i = 0; i < pl * pr; ++i) {
		ar[i] = i % pr;
		al[i] = i / pr;
	}

	int dr = 0;

	for (char c : s) {
		if (c == 'S') {
			dr ^= 1;
			for (int i = 0; i < pr; ++i) {
				p[i] = rr[p[i]];
			}
		} else if (c == 'R') {
			int z = 0;
			for (int i = 0; i < pr; ++i) {
				++p[i];
				if (p[i] == pr) {
					z = i;
					p[i] = 0;
				}
			}

			for (int i = 0; i < pl; ++i) {
				int x = i * pr + z;
				int y = al[x];
				if (dr) {
					y = rr[y];
				}
				y += 1;
				if (y == pl) {
					y = 0;
				}
				if (dr) {
					y = rr[y];
				}
				al[x] = y;
			}
		}
	}

	for (int i = 0; i < pl * pr; ++i) {
		if (dr) {
			cout << rr[al[i]] * pr + p[ar[i]] << " ";
		} else {
			cout << al[i] * pr + p[ar[i]] << " ";
		}
	}
	cout << "\n";

	return 0;
}


