#C5906. Robot Movement

    ID: 49607 Type: Default 1000ms 256MiB

Robot Movement

Robot Movement

The robot starts at the origin \((0, 0)\) on a 2D grid. It receives a sequence of commands where each command instructs the robot to move one unit in a specified direction: UP, DOWN, LEFT, or RIGHT. The robot processes the commands in order and updates its coordinates accordingly.

Your task is to compute the final coordinates of the robot after all commands have been executed. For instance, if the command sequence is UP, UP, LEFT, DOWN, RIGHT, the final coordinates of the robot will be \((0, 1)\).

inputFormat

The input is provided via standard input. The first line contains an integer (n) representing the number of commands. The following (n) lines each contain a single command, which can be one of: UP, DOWN, LEFT, or RIGHT.

outputFormat

Output the final (x) and (y) coordinates of the robot separated by a space via standard output.## sample

0
0 0