#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=600005;

int n,m;
char op[MAXN];
int a[MAXN],res[MAXN][12],temp[MAXN];
bool cf[MAXN];

int main()
{
	#ifdef LOCAL
	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n);scanf("%s",op+1);m=strlen(op+1);
	int cur=1;
	for(int i=0;i<n;++i)
	{
		memset(cf,0,sizeof(cf));
		for(int k=0;k<3*cur;++k)res[k][i]=k/cur;
		bool fl=0;
		for(int j=1;j<=m;++j)
		{
			if(op[j]=='S')
			{
				fl=!fl;
			}
			else
			{
				if(cf[a[j]]!=fl)
				{
					for(int k=0;k<3;++k)
						if(res[a[j]+k*cur][i])
							res[a[j]+k*cur][i]^=3;
					cf[a[j]]=fl;
				}
				for(int k=0;k<3;++k)
					if(res[a[j]+k*cur][i]==2)temp[j]=a[j]+k*cur,res[a[j]+k*cur][i]=0;
					else ++res[a[j]+k*cur][i];
			}
/*for(int j=0;j<cur;++j)
	if(cf[j]!=fl)
	{
		for(int k=0;k<3;++k)
			if(res[j+k*cur][i])
				res[j+k*cur][i]^=3;
		cf[j]=fl;
	}
for(int j=0;j<cur*3;++j)cerr<<res[j][i]<<" ";cerr<<endl;*/
		}
		for(int j=0;j<cur;++j)
			if(cf[j]!=fl)
			{
				for(int k=0;k<3;++k)
					if(res[j+k*cur][i])
						res[j+k*cur][i]^=3;
				cf[j]=fl;
			}
		memcpy(a,temp,sizeof(a));
		cur*=3;
//for(int j=0;j<cur;++j)cerr<<res[j][i]<<" ";cerr<<endl;
	}
	for(int i=0;i<cur;++i)
	{
		int x=i,y=cur,ans=0;
		for(int j=n-1;j>=0;--j)
		{
			y/=3;
			ans+=y*res[x][j];
			x%=y;
		}
		printf("%d ",ans);
	}
	return 0;
}