#C2541. Final Robot Position

    ID: 45869 Type: Default 1000ms 256MiB

Final Robot Position

Final Robot Position

The robot starts at the origin \( (0, 0) \) on a 2D plane. It then executes a series of movement commands. Each command instructs the robot to move one unit in one of the four directions: Up, Down, Left, or Right.

You are given an integer \( n \) representing the number of commands, followed by \( n \) commands (one per line). Your task is to compute the final coordinates \( (x, y) \) of the robot after executing all commands.

For example, if the commands are:

Up
Up
Left
Down

Then the final position is \( (-1, 1) \) because the robot moves up twice, left once and down once.

inputFormat

The input is given via standard input (stdin) and has the following format:

  • The first line contains an integer \( n \) denoting the number of commands.
  • Each of the next \( n \) lines contains a single string which is one of the following: Up, Down, Left, or Right.

outputFormat

The output should be printed to standard output (stdout) as two space-separated integers \( x \) and \( y \), representing the final coordinates of the robot.

## sample
4
Up
Up
Left
Down
-1 1