import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextLine()) { // 注意 while 处理多个 case
String num = in.nextLine();
String index = in.nextLine();
// System.out.println(index);
int N = Integer.parseInt(num);
int[] info;
// 初始化光标位置与列表
if(N<=4){
info = new int[N+1];
info[0] = 1;
for(int i=1;i<=N;i++){
info[i] = i;
}
}
else{
info = new int[]{1,1,2,3,4};
}
for(int i=0;i<index.length();i++){
if(index.charAt(i)=='U'){
up(info,N);
}
else{
down(info,N);
}
}
for(int i=1;i<info.length;i++){
System.out.print(info[i]);
if(i<info.length-1){
System.out.print(" ");
}
}
System.out.println();
System.out.println(info[0]);
}
}
// 向上翻页,info[0]:光标所在位置 info[1-4]:光标所在列表
public static int[] up(int[] info, int N) {
if (N <= 4) {
// 总数<=4,列表不变
int i = info[0];
if (i == 1) {
info[0] = N;
} else {
info[0] = i - 1;
}
} else {
int i = info[0];
// i在开头,跳到最后
if (i == 1) {
info[0] = N;
for (int j = 1; j <= 4; j++) {
info[5-j] = N - j + 1;
}
}
// 翻到上一页,整体-1
else if (i == info[1]) {
for (int j = 0; j <= 4; j++) {
info[j] --;
}
}
// 不用翻页,只动光标
else {
info[0] = info[0] - 1;
}
}
return info;
}
// 向下翻页,info[0]:光标所在位置 info[1-4]:光标所在列表
public static int[] down(int[] info, int N) {
if (N <= 4) {
// 总数<=4,列表不变
int i = info[0];
if (i == N) {
info[0] = 1;
} else {
info[0] = i + 1;
}
} else {
int i = info[0];
// i在结尾,跳到开头
if (i == N) {
info[0] = 1;
for (int j = 1; j <= 4; j++) {
info[j] = j;
}
}
// 翻到下一页,整体+1
else if (i == info[4]) {
for (int j = 0; j <= 4; j++) {
info[j] ++;
}
}
// 不用翻页,只动光标
else {
info[0] = info[0] + 1;
}
}
return info;
}
}