#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[524288];
int res[550005];

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

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));
    for(int n = 1; n <= N; n ++){
        //printf("ok");
        for(int j = 0; j < pow3[n-1]; j ++){
            D[n][j] = 0;
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        for(int j = pow3[n-1]; j < (pow3[n-1]<<1); j ++){
            D[n][j] = 1;
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        for(int j = (pow3[n-1]<<1); j < pow3[n]; j ++){
            D[n][j] = 2;
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        W[n][0] = pow3[n]-1;
    }

    //memset(lastUpdated, 0, sizeof(lastUpdated));
    int cntS2 = 0;
    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]+pow3[n-1];
            int indx2 = W[n-1][i]+(pow3[n-1]<<1);

            if(indx1 >= pow3[n]){indx1 -= pow3[n];}
            if(indx2 >= pow3[n]){indx2 -= pow3[n];}

            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'){
                D[n][indx0] = (D[n][indx0]+1);
                D[n][indx1] = (D[n][indx1]+1);
                D[n][indx2] = (D[n][indx2]+1);
                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 if(T[i] == 'S'){
                cntS ++;
            }

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

        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: 22160