# 상하좌우 문제
import sys
n = int(sys.stdin.readline())
direction_list = list(sys.stdin.readline().split())
x, y = 1, 1
go = {"R":(0,1), "U":(-1,0), "L":(0,-1), "D":(1,0)}
for direction in direction_list:
dx, dy = go[direction]
if 1 <= x + dx <= n and 1 <= y + dy <= n :
x += dx
y += dy
print(x, y)
# 시각
import sys
n = int(sys.stdin.readline())
answer = 0
three_per_hour = 0
for i in range(60):
for j in range(60):
if "3" in str(i) or "3" in str(j):
three_per_hour += 1
for i in range(n+1):
if "3" in str(i):
answer += 3600
else :
answer += three_per_hour
print(answer)
# 왕실의 나이트
import sys
location = list(sys.stdin.readline().rstrip())
dx = [-1,-2,-2,-1,1,2,2,1]
dy = [-2,-1,1,2,2,1,-1,-2]
alpha_mapping = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8}
location[0] = alpha_mapping[location[0]]
location[1] = int(location[1])
answer = 0
for i in range(8):
x = location[0] + dx[i]
y = location[1] + dy[i]
if 1<=x<=8 and 1<=y<=8 : answer += 1
print(answer)
# 문자열 재정렬
import sys
string = list(sys.stdin.readline().rstrip())
alpha_list = []
number = 0
answer = ''
for word in string:
if word.isalpha(): alpha_list.append(word)
elif word.isdigit(): number += int(word)
alpha_list.sort()
answer = ''.join(alpha_list) + str(number)
print(answer)