Paulo is always trying to sabotage the Juan group, this time he is trying to sabotage Mateo's precious strings.
Mateo has a small string $$$T$$$ consisting of distinct characters, and a big string $$$S$$$ consisting of the same characters as $$$T$$$.
Let's say that a pair of strings $$$(A, B)$$$ is good if we can duplicate the characters of $$$B$$$ a finite number of times without changing their order so that $$$A = B$$$, e.g, $$$(aabb, ab), (aabbbbbccc, abc)$$$ are good pairs, $$$(abcccc, ab), (acccb, abc)$$$ are not.
Let's define $$$cost(A, B)$$$ as the minimum number of swaps of adjacent characters in $$$A$$$ so that $$$(A, B)$$$ becomes a good pair.
Paulo knows Mateo will do anything to make the pair a good pair, Paulo can reorder the characters in $$$S$$$ and $$$T$$$ as he wishes, tell him what is the best pair $$$(S', T')$$$ such that $$$cost(S', T')$$$ is maximum.
It's guaranteed that the $$$(S, T)$$$ can be made a good pair.
The first line contains the string $$$T$$$ $$$(1 \leq |T| \leq 5)$$$, consisting of only distinct lowercase English letters.
The second line contains the string $$$S$$$ $$$(1 \leq |S| \leq 3\times10^5)$$$, consisting of only lowercase English letters.
On the first line output one integer $$$cost(S', T')$$$, then on the second line output the string $$$S'$$$, then on the third line output $$$T'$$$, such that $$$cost(S', T')$$$ is maximized.
ahmd ahmmdddmddm
39 mmmmhddddda adhm
abd abbbdddd
19 ddddbbba abd
juan juaaannnjj
36 unnnjjjaaa ajnu
abc abbcc
8 ccbba abc