Day 6 : DNA Sequencing Comparability
hardRecursion
During a genetics workshop, Dr. Morgan introduced a new method for comparing DNA sequences.
Two sequences s and t of equal length are called comparable in one of the following two cases:
- They are identical.
-
If we divide sequence s into two equal-length segments s₁ and s₂,
and sequence t into two equal-length segments t₁ and t₂, then one of the following must be true:
- s₁ is comparable to t₁, and s₂ is comparable to t₂.
- s₁ is comparable to t₂, and s₂ is comparable to t₁.
As part of a research project, Dr. Morgan has given two DNA sequences to her team and asked them to determine if they are comparable according to this definition.
Your colleague Sophia has already completed this analysis. Now it's your turn to verify her work!
Input Format:
The first two lines of the input contain two DNA sequences given by Dr. Morgan.
Each sequence has a length and consists of lowercase letters representing DNA nucleotides. The sequences have the same length.
Output Format:
Print "YES" (without the quotes) if these two sequences are comparable according to the definition, and "NO" (without the quotes) otherwise.
Constraints:
($1 \leq |length| \leq 200000$)
Examples: