const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
// Write your code here
let arr = [];
while ((line = await readline())) {
arr.push(line);
}
let count = parseInt(arr[0]);
let steps_arr = arr[1].split(""); // UDUDUD 指定的上下
let now_p = 1; // 当前位置
let now_list = [];
steps_arr.forEach((item) => {
if (item == "U") {
if (now_p == 1) {
now_p = count;
if (count > 4) {
now_list = [count - 3, count - 2, count - 1, count];
}
} else {
if ( now_list[0] == now_p) { // 光标已到最上面,还要往上走
let tmp_list = [
now_list[0] - 1,
now_list[1] - 1,
now_list[2] - 1,
now_list[3] - 1,
];
now_list = [...tmp_list];
}
now_p--;
}
} else if (item == "D") {
if (now_p == count) {
now_p = 1;
if (count > 4) {
now_list = [1, 2, 3, 4];
}
} else {
if (now_list[3] == now_p) { // 光标已到最下面,还要往下走
let tmp_list = [
now_list[0] + 1,
now_list[1] + 1,
now_list[2] + 1,
now_list[3] + 1,
];
now_list = [...tmp_list];
}
now_p++;
}
}
});
if (count <= 4) {
let route_str = "";
for (let i = 1; i <= count; i++) {
route_str = route_str + i + " ";
}
console.log(route_str);
} else {
console.log(now_list.join(" "));
}
console.log(now_p);
})();