#C2215. Final Robot Position

    ID: 45507 Type: Default 1000ms 256MiB

Final Robot Position

Final Robot Position

You are given a set of movements for a robot. The robot starts at the origin (0, 0) on a 2D plane and moves according to the following rules:

  • U: Move up by 1 unit (i.e. increase y by 1).
  • D: Move down by 1 unit (i.e. decrease y by 1).
  • L: Move left by 1 unit (i.e. decrease x by 1).
  • R: Move right by 1 unit (i.e. increase x by 1).

Your task is to compute the robot’s final position after executing the sequence of movements. Formally, given a string s, compute the point \( (x, y) \) defined by:

\( x = \text{number of R's} - \text{number of L's} \) and \( y = \text{number of U's} - \text{number of D's} \).

Input/Output: Read input from stdin and write the result to stdout. For each test case, output the final coordinates in the format x y on a separate line.

inputFormat

The input starts with a single integer T (\( 1 \le T \le 1000 \)), representing the number of test cases, followed by T lines. Each of the next T lines contains a string consisting only of the characters U, D, L, and R (possibly empty) that describes the movements.

outputFormat

For each test case, output a single line containing two integers representing the final coordinates of the robot after processing the moves: the first integer is the x-coordinate and the second is the y-coordinate, separated by a space.

## sample
2
UUDDLRLR
UUUU
0 0

0 4

</p>