#C2529. Final Coordinates Computation

    ID: 45855 Type: Default 1000ms 256MiB

Final Coordinates Computation

Final Coordinates Computation

You are given a series of movement commands which determine how a player moves on a two-dimensional plane starting from the origin ((0,0)). Each command is given in the format (\text{direction units}), where the direction is one of up, down, left, or right.

The rules for movement are as follows:

  • Moving (up) increases the y-coordinate by the specified number of units.
  • Moving (down) decreases the y-coordinate by the specified number of units.
  • Moving (left) decreases the x-coordinate by the specified number of units.
  • Moving (right) increases the x-coordinate by the specified number of units.

Your task is to compute and print the final coordinates ((x, y)) after executing all commands.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (n), which is the number of commands. Each of the following (n) lines contains a command in the format (\text{direction units}).

outputFormat

Output the final coordinates (x) and (y) separated by a space to standard output (stdout).## sample

3
up 5
left 3
down 2
-3 3