#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++)
const int pw[13]={1,3,9,27,81,243,729,2187,6561,19683,59049,177147,531441};
static inline void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
int main(void)
{
  int N,len=0,carry[200000],temp[531441],A[531441],add[531441];char T[200001];
  if(scanf("%d %s",&N,T)!=0)len=strlen(T);
  rep(i,N)
  {
    int flip=0;
    memset(add,0,pw[i]*sizeof(int));
    rep(j,len)
    {
      if(T[j]=='S'){flip^=1;}
      else
      {
        int x=carry[j];
        add[x]=(add[x]+(flip?2:1))%3;
        carry[j]+=(3-add[x])%3*pw[i];
      }
    }
    memcpy(temp,A,pw[i]*sizeof(int));
    rep(c,3){rep(j,pw[i])A[c*pw[i]+j]=temp[j]+(flip?2:1)*(c+add[j])%3*pw[i];}
  }
  rep(i,pw[N])OUT(A[i]),putchar(' ');
}