import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total = Integer.parseInt(sc.nextLine());
        String operations = sc.nextLine();
        int[] data = new int[total];
        for (int i = 0; i < total; i++) {
            data[i] = i + 1;
        }
        int size = total < 4 ? total : 4;
        int[] win = new int[size];
        for (int i = 0; i < size; i++) {
            win[i] = i + 1;
        }
        int[] initWin = new int[size];
        System.arraycopy(win, 0, initWin, 0, win.length);
        int cur = 0;
        for (int i = 0; i < operations.length(); i++) {
            char oper = operations.charAt(i);
            if (oper == 'U') {
                if (win[cur] == data[0]) {
                    // 第一个数,total>4,窗口到底,光标到底
                    // 第一个数,total<=4,窗口不动,光标到len-1
                    if (total > 4) {
                        for (int j = 0; j < 4; j++) {
                            win[j] = data[total - 1 - (3 - j)];
                        }
                        cur = 3;
                    } else {
                        cur = total - 1;
                    }
                } else {
                    // 光标=0,窗口上移,光标不动
                    // 光标>0,窗口不动,光标-1
                    if (cur == 0) {
                        moveWin(win, -1);
                    } else {
                        cur--;
                    }
                }
            } else if (oper == 'D') {
                if (win[cur] == data[total - 1]) {
                    // 最后一个数:窗口重置,光标重置
                    System.arraycopy(initWin, 0, win, 0, initWin.length);
                    cur = 0;
                } else {
                    if (cur < 3) {
                        // 光标<3:窗口不动,光标+1
                        cur++;
                    } else {
                        // 光标=3(底部),窗口下移1,光标不动
                        moveWin(win, 1);
                    }
                }
            } else {
                throw new RuntimeException("invalid oper");
            }
        }
        for (int v : win) {
            System.out.print(v + " ");
        }
        System.out.println();
        System.out.println(win[cur]);
    }

    private static void moveWin(int[] win, int dt) {
        for (int i = 0; i < win.length; i++) {
            win[i] = win[i] + dt;
        }
    }
}