import sys
import re
raw_input = []
for i,line in enumerate(sys.stdin):
raw_input.append(line.strip())
if i == 1:
break
command_dict = {'A':(-1, 0), 'D':(1, 0), 'W':(0, 1), 'S':(0, -1)}
command_regex = re.compile(r'^([ADWS])(\d+)$')
command_lst = raw_input[0].split(';')
pos = [0, 0]
for command in command_lst:
regex_match = re.match(command_regex, command)
if regex_match is None:
continue
else:
direction, dist = regex_match.group(1), int(regex_match.group(2))
if dist > 99 or dist < 1:
continue
dx, dy = command_dict[direction]
pos[0] += dx*dist
pos[1] += dy*dist
# print(pos)
print(f'{pos[0]},{pos[1]}')