#K72987. Final Robot Position

    ID: 33875 Type: Default 1000ms 256MiB

Final Robot Position

Final Robot Position

You are given a string representing a sequence of commands for a robot. The commands consist only of the characters U, D, L, and R, corresponding to movements Up, Down, Left, and Right, respectively. The robot starts at ( (0,0) ) on a Cartesian plane. For each command, the robot moves one unit in the corresponding direction.

Your task is to compute the final position of the robot after executing all commands.

For example, given the command string UURR, the final position will be ( (2, 2) ).

inputFormat

The input is read from standard input (stdin). The first line contains a single integer ( T ) representing the number of test cases. Each of the following ( T ) lines contains a non-empty string of commands consisting only of the characters U, D, L, and R.

outputFormat

For each test case, output the final coordinates of the robot as two space-separated integers on a new line to standard output (stdout).## sample

3
UURR
DDLL
UDLR
2 2

-2 -2 0 0

</p>