Problem I: Inversing Palindrome
You are given two zero-indexed binary strings a and b, each string having length n. You can
perform the following operation any number of times (possibly zero):
• Choose a palindromic substring of a with an even length, and flip all digits in the chosen
substring (every digit 0 is turned into digit 1, and vice-versa).
Determine whether it is possible to transform string a into string b.
Input
The first line contains a positive integer t (1 ≤ t ≤ 104 ) – the number of test cases. The
description of each test case is as follows.
The first line contains a positive integer n (2 ≤ n ≤ 100) – the length of the two binary strings.
The second line contains a binary string a of length n.
The third line contains a binary string b of length n.
It is guaranteed that the sum of n over all test cases does not exceed 2 · 105 .
Output
For each test case, print "YES" (without quotes) if you can transform string a into string b.
Otherwise, print "NO" (without quotes).
Sample Explanation
In the first test case, a possible way to transform string a into string b is described as follows:
[0;3] [3;4]
10010 −−→ 01100 −−→ 01111
In the second test case, it is impossible to perform any operation on string a. Therefore, it is
impossible to transform string a into a different string.
In the third test case, no operation is need to transform string a into string b.
Sample Input 1 Sample Output 1
3 YES
5 NO
10010 YES
01111
3
101
110
4
0000
0000
Vietnam National 2024 Problem I: Inversing Palindrome 17