#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define putchar_unlocked putchar

char T[500005];
int res[531443];

// Based on editorial solution
int D[13][531443]; // one digit at a time, with digit 0 representing the ones place
int W[13][531443];
int lastUpdated[13][531443];

int x[11];
inline void putInt(int i){
    if(i==0){putchar_unlocked('0');}
    else{
    int count1=0;
    while(i>0){
        x[count1++]=i%10;
        i/=10;
    }
    for(int j=count1-1;j>=0;j--){
        putchar_unlocked(48+x[j]);
    }
    }
    putchar_unlocked(' ');
}

int N;

inline void update(int n, int indx, int cntS){
    if( ((cntS&1) != (lastUpdated[n][indx]&1)) && D[n][indx]){
        // conduct salsa
        D[n][indx] = 3-D[n][indx];
    }
    // update the lastUpdated index
    lastUpdated[n][indx] = cntS;
}

int pow3[16];

int main(){
    scanf("%d", &N);
    scanf(" %s", T);

    int M = strlen(T);

    pow3[0] = 1;
    for(int i = 1; i <= N; i ++){
        pow3[i] = pow3[i-1]*3;
    }

    //memset(W, 0, sizeof(W));
    int tempNum = 1;
    for(int n = 1; n <= N; n ++){
        //printf("ok");
        for(int j = 0; j < tempNum; j ++){
            D[n][j] = 0;
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        for(int j = tempNum; j < (tempNum<<1); j ++){
            D[n][j] = 1;
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        for(int j = (tempNum<<1); j < 3*tempNum; j ++){
            D[n][j] = 2;
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        W[n][0] = pow3[n]-1;
        tempNum *= 3;
    }

    //memset(lastUpdated, 0, sizeof(lastUpdated));
    int cntS2 = 0;
    tempNum = 1;
    int tempNum2 = 3;
    for(int n = 1; n <= N; n ++){
        int cntS = 0;
        for(int i = 0; i < M; i ++){
            int indx0 = W[n-1][i];
            int indx1 = W[n-1][i]+tempNum;
            int indx2 = W[n-1][i]+(tempNum<<1);

            if(indx1 >= tempNum2){indx1 -= tempNum2;}
            if(indx2 >= tempNum2){indx2 -= tempNum2;}

            update(n, indx0, cntS+(T[i]=='S'));
            update(n, indx1, cntS+(T[i]=='S'));
            update(n, indx2, cntS+(T[i]=='S'));
            if(D[n][indx0] == 2){
                W[n][i] = indx0;
            }else if(D[n][indx1] == 2){
                W[n][i] = indx1;
            }else{
                W[n][i] = indx2;
            }

            if(T[i] == 'R'){
                if( (++D[n][indx0]) == 3){D[n][indx0] = 0;}
                if( (++D[n][indx1]) == 3){D[n][indx1] = 0;}
                if( (++D[n][indx2]) == 3){D[n][indx2] = 0;}
                lastUpdated[n][indx0] = cntS;
                lastUpdated[n][indx1] = cntS;
                lastUpdated[n][indx2] = cntS;
            }else{
                cntS ++;
            }

            //printf("W[%d][%d]=%d\n", n, i+1, W[n][i+1]);
        }

        tempNum *= 3;
        tempNum2 *= 3;

        cntS2 = cntS;
    }

    for(int n = 1; n <= N; n ++){
        for(int i = 0; i < pow3[n]; i ++){
            update(n, i, cntS2);
        }

        int cnt = 0;
        for(int i = 0; i < pow3[N]; i ++){
            res[i] += D[n][cnt++]*pow3[n-1];
            if(cnt == pow3[n]){cnt = 0;}
        }
    }

    for(int i = 0; i < pow3[N]; i ++){
        /*int temp = 0;
        for(int n = 1; n <= N; n ++){
            temp += D[n][i%pow3[n]]*pow3[n-1];
        }*/
        //putInt(temp);
        putInt(res[i]);
    }

    return 0;
}


Measured memory_bytes: 22200