#include <stdio.h>
#include <stdlib.h>

int new_pos(int num){
    int j=1,ans=0;
    for(j=1;;){
        if(num<3){
            if(num==1) ans = ans + 2*j;
            else if(num==2) ans = ans + 1*j;
            break;

        }
        else{
            if(num%3==1) ans = ans+2*j;
            else if(num%3==2) ans = ans+1*j;
            num = num/3;
        }
        j=j*3;
    }
    return ans;
}

int main()
{
    int n,i,j,r=0,s=0;
    int pos[531441]={};
    char t[200000]={};
    scanf("%d",&n);
    for(i=0;i<(int)pow(3,n);i++) pos[i]=i;
    scanf("%s",&t);
    for(i=0;i<=strlen(t);i++){
        if(s==0&&t[i]=='R') r++;
        else if(r==0&&t[i]=='S') s++;
        else if(r!=0&&t[i]!='R'){
            for(j=0;j<(int)pow(3,n);j++){
                pos[j] = (pos[j]+r)%((int)(pow(3,n)));
            }
            r = 0;
            s++;
        }
        else if(s!=0&&t[i]!='S'){
            if(s%2==0) s = 0;
            else{
                for(j=0;j<(int)pow(3,n);j++) pos[j] = new_pos(pos[j]);
                s = 0;
            }
            r++;
        }
    }
    for(i=0;i<(int)pow(3,n);i++) printf("%d ",pos[i]);
    return 0;
}
