747. String Equivalence
0
Medium
During the CodSule 2019 event in India, a tourist and Rajat were discussing problems related to divide and conquer. The tourist asked Rajat if he could determine whether two strings, s1 and s2, are equivalent. Rajat then inquired about the conditions for equivalence, to which the tourist replied:
Two strings, a and b, of equal length are considered equivalent if one of the following conditions is met:
- They are exactly the same.
- If we split string a into two halves of equal size, a1 and a2, and string b into two halves of equal size, b1 and b2, then one of the following must be true:
- a1 is equivalent to b1, and a2 is equivalent to b2
- a1 is equivalent to b2, and a2 is equivalent to b1
Rajat quickly solved the problem. Can you?
Input Format
The first line contains the number of test cases, t. Each subsequent line contains two strings of equal length.
Output Format
Print "YES" if the strings are "equivalent", and "NO" if they are not.
Example
Input
3
ababa
baaba
ab
ba
abc
abc
Output
NO
YES
YES
Constraints
1 <= test cases <= 10
1 <= string length <= 50000
Loading...
View Submissions
Console