#C12174. Simulate Object Movement

    ID: 41572 Type: Default 1000ms 256MiB

Simulate Object Movement

Simulate Object Movement

You are given a sequence of movements for an object starting at the origin \((0, 0)\). Each movement is represented by a direction and a distance. The directions can be UP, DOWN, LEFT, or RIGHT. Your task is to compute the final coordinates of the object after performing all the movements.

The object initially starts at \((0, 0)\). For each movement:

  • If the direction is UP, increase the y-coordinate by the given distance.
  • If the direction is DOWN, decrease the y-coordinate by the given distance.
  • If the direction is LEFT, decrease the x-coordinate by the given distance.
  • If the direction is RIGHT, increase the x-coordinate by the given distance.

Finally, output the final x and y coordinates separated by a space.

inputFormat

The input is read from stdin and has the following format:

  1. An integer \(n\) representing the number of movements.
  2. \(n\) lines follow, each line contains a string and an integer separated by space. The string represents the direction (UP, DOWN, LEFT, or RIGHT) and the integer represents the distance.

outputFormat

Print the final x and y coordinates separated by a space. The output is written to stdout.

## sample
0
0 0

</p>