harbor run -t openthoughts/tasktrove-code-contests-noblock-code_contests-3466harbor download openthoughts/tasktrove-code-contests-noblock-code_contests-3466There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U'. When a command is executed, the robot simply moves in the corresponding direction:
Your task is to put an obstacle in one cell of the field so that after executing the commands, the robot will return to the original cell of its path (0, 0). Of course, an obstacle cannot be placed in the starting cell (0, 0). It is guaranteed that if the obstacle is not placed, then the robot will not return to the starting cell.
An obstacle affects the movement of the robot in the following way: if it tries to go in a certain direction, and there is an obstacle, then it simply remains in place (the obstacle also remains, that is, it does not disappear).
Find any such cell of the field (other than (0, 0)) that if you put an obstacle there, the robot will return to the cell (0, 0) after the execution of all commands. If there is no solution, then report it.
Input
The first line contains one integer t (1 ≤ t ≤ 500) — the number of test cases.
Each test case consists of a single line containing s — the sequence of commands, which are uppercase Latin letters 'L', 'R', 'D', 'U' only. The length of s is between 1 and 5000, inclusive. Additional constraint on s: executing this sequence of commands leads the robot to some cell other than (0, 0), if there are no obstacles.
The sum of lengths of all s in a test doesn't exceed 5000.
Output
For each test case print a single line:
If there are multiple answers, you can print any of them.
Example
Input
4 L RUUDL LLUU DDDUUUUU
Output
-1 0 1 2 0 0 0 1
Solve this competitive programming problem.
Write a complete, self-contained Python solution to /app/solution.py.
Your solution must:
/app/solution.pyImportant: Your solution will be executed non-interactively as:
python3 /app/solution.py < input.txt
Do not use input() in a loop that waits for interactive input. Read all
input at once (e.g. import sys; data = sys.stdin.read()) and process it.
The solution will be validated against multiple test cases.