#应该是栈的使用,进一个出一个。当前播放歌曲好判断,难处在于列表该如何输出。在大于4的情况下需要考虑栈的输入输出。
w = int(input())
n = input()wq = 1
if w > 4:
b = [1, 2, 3, 4]
for i in range(len(n)):
if n[i] == 'U' and wq == 1:
wq = w
b = [w-3, w-2, w-1, w]
elif n[i] == 'U' and wq != 1:
wq = wq - 1
if wq + 1 == b[0]:
b.pop(-1)
b.insert(0, wq)
elif n[i] == 'D' and wq == w:
wq = 1
b = [1, 2, 3, 4]
elif n[i] == 'D' and wq != w:
wq = wq + 1
if wq - 1 == b[-1]:
b.pop(0)
b.append(wq)
a = list(map(str,b))
print(' '.join(a))
print(wq)
else:
b = [i for i in range(1, w+1)]
for i in range(len(n)):
if n[i] == 'U' and wq == 1:
wq = w
elif n[i] == 'U' and wq != 1:
wq = wq - 1
elif n[i] == 'D' and wq == w:
wq = 1
elif n[i] == 'D' and wq != w:
wq = wq + 1
a = list(map(str,b))
print(' '.join(a))
print(wq)