#C6289. Robot Final Position

    ID: 50032 Type: Default 1000ms 256MiB

Robot Final Position

Robot Final Position

The problem is to compute the final position of a robot on a two-dimensional grid. The robot starts at the origin, (0, 0), and follows a sequence of commands. Each command consists of a direction letter followed immediately by the number of steps to move in that direction. The directions are given as (N) (north), (S) (south), (E) (east), and (W) (west). Your task is to output the final position of the robot as two integers separated by a space.

The command string format adheres to the following rules: a single uppercase letter, one of N, S, E, or W, immediately followed by a positive integer. For example, the command "N5" moves the robot 5 steps to the north.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (N), representing the number of commands. The following (N) lines each contain one command string. For instance:

4
N5
E10
S3
W2

outputFormat

Output to standard output (stdout) the final coordinates of the robot as two integers separated by a space. For the sample input above, the output should be:

8 2## sample

4
N5
E10
S3
W2
8 2

</p>