s = input().strip().split(';')
m = []
if i[0] in ('A','S','D','W') and i[1].isdigit() and i[2].isdigit():
m.append(i)
x = 0
y = 0
for i in m:
if i[0] == 'A':
x -= int(i[1:])
if i[0] == 'D':
x += int(i[1:])
if i[0] == 'W':
y += int(i[1:])
if i[0] == 'S':
y -= int(i[1:])
print(x,y,sep=(','))
m = []
for i in s: #只有两种坐标情况:1、('A','S','D','W')+一个数字 2、('A','S','D','W')+两个数字,其他弃置。
if len(i) == 2:
if i[0] in ('A','S','D','W') and i[1].isdigit():
m.append(i)
elif len(i) == 3:if i[0] in ('A','S','D','W') and i[1].isdigit():
m.append(i)
if i[0] in ('A','S','D','W') and i[1].isdigit() and i[2].isdigit():
m.append(i)
x = 0
y = 0
for i in m:
if i[0] == 'A':
x -= int(i[1:])
if i[0] == 'D':
x += int(i[1:])
if i[0] == 'W':
y += int(i[1:])
if i[0] == 'S':
y -= int(i[1:])
print(x,y,sep=(','))