#K15606. Drone Final Coordinates
Drone Final Coordinates
Drone Final Coordinates
You are given instructions for a set of drones. Each drone starts at the origin \((0, 0)\) on a 2D plane. Each drone receives a sequence of commands to move in one of four directions: left (L), right (R), up (U), and down (D). The command 'L' subtracts from the x-coordinate, 'R' adds to the x-coordinate, 'U' adds to the y-coordinate, and 'D' subtracts from the y-coordinate.
Your task is to compute the final coordinates \((x, y)\) for each drone after following all its instructions.
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer \(T\) denoting the number of drones.
- For each drone, the first line contains an integer \(n\), the number of moves.
- This is followed by \(n\) lines, each containing a character and an integer separated by a space. The character is one of 'L', 'R', 'U', or 'D', and the integer represents the number of units to move in that direction.
outputFormat
For each drone, output a single line on stdout containing two space-separated integers representing the final x and y coordinates.
## sample2
3
R 10
U 5
L 15
4
U 20
R 50
D 25
L 10
-5 5
40 -5
</p>