i = input()
lt = i.split(';')
local = [0,0]
for k in lt:
if not 2<= len(k) <=3:
continue
try:
direction = k[0]
distance = int(k[1:])
if direction in ['A','S','D','W']:
if 0<=distance<=99:
if direction == 'A':
local[0]=local[0]-distance
elif direction == 'S':
local[1]=local[1]-distance
elif direction == 'D':
local[0]=local[0]+distance
elif direction == 'W':
local[1]=local[1]+distance
except:
continue
print(str(local[0])+','+str(local[1]))
lt = i.split(';')
local = [0,0]
for k in lt:
if not 2<= len(k) <=3:
continue
try:
direction = k[0]
distance = int(k[1:])
if direction in ['A','S','D','W']:
if 0<=distance<=99:
if direction == 'A':
local[0]=local[0]-distance
elif direction == 'S':
local[1]=local[1]-distance
elif direction == 'D':
local[0]=local[0]+distance
elif direction == 'W':
local[1]=local[1]+distance
except:
continue
print(str(local[0])+','+str(local[1]))