import re, sys for input_data in sys.stdin: steps_ori = input_data.split(';') steps = [x for x in steps_ori if re.match('[ASWD]{1}[0-9]{1,2}$', x)] coordinate = [0, 0] for step in steps: direction = step[0] move_count = int(step[1:]) if direction == 'A': coordinate[0] -= move_count elif direction == 'D': coordinate[0] += move_count elif direction == 'W': coordinate[1] += move_count else: coordinate[1] -= move_count print(','.join([str(x) for x in coordinate]))