#K35262. Final Position After Movements
Final Position After Movements
Final Position After Movements
You are given t test cases. In each test case, you receive a string representing a sequence of moves. Each character of the string is one of 'U', 'D', 'L', and 'R', denoting up, down, left, and right moves respectively.
The robot starts at the origin (0, 0) in the Cartesian plane. After processing each move in the sequence, its final coordinate (x, y) is computed. The coordinates are updated according to the formulas:
$$x = \text{number of R moves} - \text{number of L moves}$$ $$y = \text{number of U moves} - \text{number of D moves}$$
Your task is to determine the final coordinates for each test case and output the results. Each coordinate pair should be printed on a new line with the x and y values separated by a space.
inputFormat
The input is read from standard input and is formatted as follows:
- The first line contains an integer t — the number of test cases.
- The following t lines each contain a non-empty string representing a sequence of moves.
outputFormat
For each test case, output a line containing two space-separated integers x and y, which represent the final coordinates after performing the moves.
## sample3
UUDDLRLR
RRUULLDD
UDLR
0 0
0 0
0 0
</p>