#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline char CH(void)
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
static inline void OUT(int x){if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline int Pow(int a,int b){return b?Pow(a*a,b>>1)*(b&1?a:1):1;}
int main()
{
  int N,now,len=0,A[531441],B[531441];char T[200001],S[200000];
  now=scanf("%d %s",&N,T);len=strlen(T);fflush(stdin);
  int pw3=Pow(3,N),x=Pow(3,N>>1),y=Pow(3,N-(N>>1));
  rep(i,pw3)B[i]=B[i/3]*3+(3-i%3)%3;
  rep(i,x)
  {
    int temp=i;now=0;
    rep(j,len)
    {
      if(T[j]=='S'){temp=B[temp];if(S[now]=='S')--now;else S[++now]='S';}
      else{++temp;if(temp==x)S[++now]='R',temp=0;}
    }
    rep(j,y)
    {
      int keep=j;
      rep(k,now)
      {
        if(S[k+1]=='S')keep=B[keep];
        else if(S[k+1]=='R')if((++keep)==y)keep=0;
      }
      A[i+j*x]=temp+keep*x;
    }
  }
  rep(i,pw3)OUT(A[i]),putchar(' ');
  return fflush(stdout),0;
}