from sys import stdin input = lambda: stdin.readline().strip() x,y = 0,0 l = input().split(";") def f(q): global x,y try: move1,len1 = q[0],int(q[1:]) if 1<=len1<=99: if move1 == "A": x,y = x-len1,y if move1 == "D": x,y = x+len1,y if move1 == "S": x,y = x,y-len1 if move1 == "W": x,y = x,y+len1 except: pass for i in l: f(i) print(x,y,sep=",")