You work at a secret communications office, where every day you handle mysterious messages encoded in lowercase letters. One day, you receive two messages, both containing exactly the same number of letters. Your mission is to transform the first message $$$S$$$ into the second message $$$T$$$ using a very special operation.
The operation you can perform consists of two parts:
Note: If the chosen indices $$$i$$$ and $$$j$$$ are adjacent, the operation simply swaps the two letters, as there are no letters between them to flip.
Your goal is to determine the minimum number of operations required to transform $$$S$$$ into $$$T$$$. If it is impossible to transform $$$S$$$ into $$$T$$$ using these operations, output $$$-1$$$.
The first line contains an integer $$$n$$$ ($$$2 \le n \le 7$$$) — the length of the strings.
The second line contains a string $$$S$$$ of length $$$n$$$, consisting of lowercase English letters.
The third line contains a string $$$T$$$ of length $$$n$$$, also consisting of lowercase English letters.
Print a single integer: the minimum number of operations required to transform $$$S$$$ into $$$T$$$, or $$$-1$$$ if it is impossible.
3abcxyz
7
6codemimeowic
6
3cdeeyd
-1
Testcase 1: $$$$$$ \begin{array}{rcl} \texttt{abc} \xrightarrow{\text{1}} \texttt{cya} \xrightarrow{\text{2}} \texttt{yca} \xrightarrow{\text{3}} \texttt{axy} \xrightarrow{\text{4}} \texttt{xay} \xrightarrow{\text{5}} \texttt{yzx} \xrightarrow{\text{6}} \texttt{yxz} \xrightarrow{\text{7}} \texttt{xyz} \end{array}$$$$$$