#C5694. Final Coordinates Calculation

    ID: 49371 Type: Default 1000ms 256MiB

Final Coordinates Calculation

Final Coordinates Calculation

You are given a string that represents a sequence of moves. Each move is indicated by one of the following characters:

  • L: Move left by one unit.
  • R: Move right by one unit.
  • U: Move up by one unit.
  • D: Move down by one unit.

Starting at the origin \((0,0)\), simulate the moves specified in the string and determine the final coordinates \((x,y)\) after performing all moves. Formally, if you let \(\Delta x\) and \(\Delta y\) represent the changes along the x-axis and y-axis respectively, then for each move you update the coordinates as follows:

[ \begin{aligned} \text{if move == 'L'} & : x=x-1,\ \text{if move == 'R'} & : x=x+1,\ \text{if move == 'U'} & : y=y+1,\ \text{if move == 'D'} & : y=y-1. \end{aligned} ]

For each test case, output the final coordinates in the format "x y".

inputFormat

The first line of input contains a single integer T (1 ≤ T ≤ 103) representing the number of test cases. Each of the following T lines contains a non-empty string consisting solely of the characters 'L', 'R', 'U', and 'D'.

outputFormat

For each test case, output a single line containing two integers separated by a space, representing the final coordinates x and y.

## sample
3
LLRR
UUDD
LURDLURD
0 0

0 0 0 0

</p>