// 利用数组 array<int,4> dq{0}; 来模拟菜单

#include <array>
#include <deque>
#include <iostream>
using namespace std;

int main() {
    int n;
    string command;
    cin >> n >> command;
    int len  = command.length();
    int pos = 1;
    array<int,4> dq{0};
    if(n <= 4 ){
        for(int i = 0 ; i < len; ++i){
            if(command[i] == 'U'){
                if(--pos == 0){
                    pos = n;
                }
            }else{
                if(++pos == n+1){
                    pos = 1;
                }
            }
        }
        for(int i = 0 ; i < n; ++i){
            cout << i+1 << " ";
        }
        cout << endl;
        cout << pos << endl;
    }
    else{
        //采用滑动窗口
        for(int i = 0 ; i < 4; ++i){
            dq[i] = i + 1;
        }
        for(int i = 0 ; i < len; ++i){
            if(command[i] == 'U'){
                if(--pos == 0){
                    pos = n;
                    //采用滑动窗口
                    for(int j = 0 ; j < 4; ++j){
                        dq[j] = n - 4 + j + 1;
                    }
                }else{
                    if(pos == dq[0]-1){
                        for(int j = 0 ; j < 4; ++j){
                            dq[j] -= 1;
                        }
                    }
                    
                }
            }else{
                if(++pos == n+1){
                    pos = 1;
                    //采用滑动窗口
                    for(int j = 0 ; j < 4; ++j){
                        dq[j] = j + 1;;
                    }
                }else{
                    if(pos == dq[3]+1){
                        for(int j = 0 ; j < 4; ++j){
                            dq[j] += 1;;
                        }
                    }
                    
                }
            }
        }

        for(auto p : dq){
            cout << p << " ";
        }
        cout << endl;
        cout << pos << endl;
    }
}
// 64 位输出请用 printf("%lld")