Question
Scroll Spell
In a mystical realm, sage Lila holds two enchanted parchments. One bears a string S of length N, the other a string X of length M.
Lila can shuffle the letters of both parchments freely. Her task is to reshape them into
S’ and X’, then merge them (S’ + X’) to form a palindrome that reads the same forwards and backwards.
Determine if such a magical palindrome can be crafted.
Lila can shuffle the letters of both parchments freely. Her task is to reshape them into
S’ and X’, then merge them (S’ + X’) to form a palindrome that reads the same forwards and backwards.
Determine if such a magical palindrome can be crafted.
Input
The first line contains a single integer T - the number of test cases. Then the test cases follow.
The first line of each test case contains two integers N and M - the length of the strings S and X respectively.
The second line of each test case contains a string S of length N containing lowercase Latin letters only.
The third line of each test case contains a string X of length M containing lowercase Latin letters only.
The first line of each test case contains two integers N and M - the length of the strings S and X respectively.
The second line of each test case contains a string S of length N containing lowercase Latin letters only.
The third line of each test case contains a string X of length M containing lowercase Latin letters only.
Output
For each test case, output "Yes" if we can rearrange S and X such that (S′ + X′) becomes a palindrome. Otherwise, output "No" (without quotes).
Example
Sample Input
2
5 2
abcdd
ac
3 3
abc
xyz
Sample Output
Yes
No
Explanation
Test case 1: We can rearrange P to P' = acdbd and Q to Q' = ca. so P' + Q' = acdbdca which is palindromic.
Test case 2: We can not rearrange P and Q such that P' + Q′ is palindromic.
2
5 2
abcdd
ac
3 3
abc
xyz
Sample Output
Yes
No
Explanation
Test case 1: We can rearrange P to P' = acdbd and Q to Q' = ca. so P' + Q' = acdbdca which is palindromic.
Test case 2: We can not rearrange P and Q such that P' + Q′ is palindromic.