Problem: There is a binary string of length . In one operation, you can select any prefix of with an equal number of and symbols. Then all symbols in the prefix are inverted: each becomes and each becomes .
For example, suppose .
- In the first operation, we can select the prefix of length since it has four 's and four 's: .
- In the second operation, we can select the prefix of length since it has one and one : .
- It is illegal to select the prefix of length for the third operation, because it has three 's and one .
Can you transform the string into the string using some finite number of operations (possibly, none)?
Input Format: The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of the strings and .
The following two lines contain strings and of length , consisting of symbols and .
The sum of across all test cases does not exceed .
Output Format: For each test case, output "YES" if it is possible to transform into , or "NO" if it is impossible. You can print each letter in any case (upper or lower).
Note: The first test case is shown in the statement.
In the second test case, we transform into by using zero operations.
In the third test case, there is no legal operation, so it is impossible to transform into .
In the fourth test case, here is one such transformation:
- Select the length prefix to get .
- Select the length prefix to get .
- Select the length prefix to get .
- Select the length prefix to get .
- Select the length prefix to get .
In the fifth test case, the only legal operation is to transform into . From there, the only legal operation is to return to the string we started with, so we cannot transform into .