#K57372. Remove All Characters
Remove All Characters
Remove All Characters
You are given a string s consisting of lowercase letters. You are allowed to repeatedly perform the following operation:
\(\text{If two adjacent characters are equal, remove them both}\)
The goal is to determine whether it is possible to completely remove all characters from the string by repeatedly applying the above operation.
For example, consider the string "abba":
- Remove the adjacent "bb" to get "aa".
- Then remove the adjacent "aa" to get an empty string.
If the string can be fully reduced to an empty string, output YES
; otherwise, output NO
.
inputFormat
The first line of input contains a single integer T (\(1 \le T \le 10^5\)), the number of test cases.
Each of the following T lines contains a non-empty string s consisting of lowercase letters.
You should read the input from standard input (stdin).
outputFormat
For each test case, output a single line containing either YES
if it is possible to remove all characters from the string, or NO
otherwise.
Write the output to standard output (stdout), with each answer on a new line.
## sample3
abba
aaa
abc
YES
NO
NO
</p>