x, y = 0, 0 while True: s = input() if s == "СТОП": break elif s == "СЕВЕР": y += int(input()) elif s == "ЮГ": y -= int(input()) elif s == "ЗАПАД": x -= int(input()) elif s == "ВОСТОК": x += int(input()) print(y) print(x)