You are given two strings \(S\) and \(T\) each of length \(N\) consisting of lowercase English letters. In one operation, you can swap any two characters of \(S\) if the absolute difference between their indices is a multiple of \(2\). You may perform this operation any number of times. The absolute difference between indices \(i\) and \(j\) will be \(|i - j|\).
Print \(Yes\) if you can convert \(S\) into \(T\) after some operations else print \(No\).
Input format
- The first line contains an integer \(T\), denoting the number of test cases.
- The first line of each test case contains an integer \(N\), denoting the length of the string.
- The second line of each test case contains the string \(S\).
- The third line of each test case contains the string \(T\).
Output format
For each test case, print \(Yes\) if you can convert \(S\) into \(T\) after some operations else print \(No\) in a separate line.
Constraints
3 2 ab ab 4 ashe dhwa 5 ahsde edahs
Yes No Yes
For test case \(1\): \(S\) is already equal to \(T\). Hence, the answer is \(Yes\).
For test case \(2\): \(S\) cannot be converted into \(T\). Hence, the answer is \(No\).
For test case \(3\):
- We can swap elements at indexes \(1\) and \(3\).
- We can swap elements at indexes \(4\) and \(2\).
- We can swap elements at indexes \(0\) and \(2\).
- After the above operations, \(S\) can convert into \(T\). Hence, the answer is \(Yes\).
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor