import sys
while True:
    try:
        n = int(input())
        s = input()
        pos = 0
        lst = list(range(1,n+1))
        if n <= 4:
            bod = lst[:]
            for c in s:
                if c == 'U':
                    if pos == 0:
                        pos = n - 1
                    else:
                        pos -= 1
                elif c == 'D':
                    if pos == n - 1:
                        pos = 0
                    else:
                        pos += 1
        else:
            bod = lst[:4]
            for c in s:
                if c == 'U':
                    if pos == 0:
                        if bod[0] == lst[0]:
                            pos = 3
                            bod = lst[-4:]
                        else:
                            start_index = lst.index(bod[0]) - 1
                            bod = lst[start_index:start_index+4]
                    else:
                        pos -= 1
                if c == 'D':
                    if pos == 3:
                        if bod[3] == lst[-1]:
                            pos = 0
                            bod = lst[:4]
                        else:
                            start_index = lst.index(bod[0]) + 1
                            bod = lst[start_index:start_index+4]
                    else:
                        pos += 1
        out = ' '.join(map(str,bod))
        print(out)
        print(bod[pos])
            
    except:
        break