#C11673. Robot Return to Origin
Robot Return to Origin
Robot Return to Origin
The problem is to determine whether a robot returns to its original position after executing a series of moves. The robot starts at the origin \( (0, 0) \) and can move one unit at a time in one of four directions: up ('U'), down ('D'), left ('L'), and right ('R'). After executing all moves in a given sequence, the robot is said to return to the origin if its coordinates satisfy \( x = 0 \) and \( y = 0 \).
You are given multiple move sequences. For each sequence, determine if the robot returns to the origin.
Note: An empty move sequence is considered as remaining at the origin.
inputFormat
The first line of input contains an integer \( T \) \( (1 \leq T \leq 10^5) \) representing the number of test cases.
Each of the following \( T \) lines contains a single string composed of the characters 'U', 'D', 'L', and 'R', representing the sequence of moves.
outputFormat
For each test case, output a single line "YES" if the robot returns to the origin after executing the moves, otherwise output "NO".
## sample3
UD
LLRR
UUDDLLRR
YES
YES
YES
</p>