#按照提示写逻辑即可
import sys
while True:
try:
N = int(input())
l = [i for i in range(1, N + 1)]
g_index = 1
s = l[g_index - 1:4]
orders = input()
# print(l, orders,s)
if N <= 4:
for o in orders:
if o == 'U':
if g_index == 1:
g_index = N
else:
g_index -= 1
else:
if g_index == N:
g_index = 1
else:
g_index += 1
else:
for o in orders:
if o == 'U':
if g_index == 1:
g_index = N
s = l[g_index - 4:g_index]
elif l[g_index - 1] == s[0]:
g_index -= 1
s = l[g_index - 1:g_index + 3]
else:
g_index -= 1
else:
if g_index == N:
g_index = 1
s = l[g_index - 1:g_index + 3]
elif l[g_index - 1] == s[3]:
g_index += 1
s = l[g_index - 4:g_index]
else:
g_index += 1
print(" ".join(map(str,s)))
print(g_index)
except:
# print(sys.exc_info())
break



京公网安备 11010502036488号