while True:
try:
n = int(input())
actions = input()
songs = [i for i in range(1,n+1)]
new_songs =[]
maus_pos = 0
page_pos = 0
for act in actions:
if act == 'U' and maus_pos == 0:
maus_pos = n-1
page_pos =3
elif act == 'U':
maus_pos -=1
if page_pos==0:
page_pos = 0
else:
page_pos -=1
elif act == 'D' and maus_pos == n-1:
maus_pos = 0
page_pos = 0
elif act == 'D':
maus_pos += 1
if page_pos == 3:
page_pos =3
else:
page_pos +=1
if n<=4:
new_songs = songs
else:
value = songs[maus_pos]
new_songs=[i for i in range(value-page_pos,value-page_pos+4)]
print(" ".join(list(map(str,new_songs))))
print(songs[maus_pos])
except:
break