n = int(input())
data = input().split()
x = 1 #행
y = 1 #열
go = [(0, -1), (0, 1), (-1, 0), (1, 0)] #L R U D 이동하기 위해서
LRUD = ['L', 'R', 'U', 'D']
for i in data:
new_x = x + go[LRUD.index(i)][0] #새로운 x좌표
new_y = y + go[LRUD.index(i)][1] #새로운 y좌표
#범위를 벗어나면 넘어가기
if new_x < 1 or new_y < 1 or new_x > n or new_y > n:
continue
x = new_x
y = new_y
print(x, y)