Question
The Perfumer's Scent Blend Orders

A perfumer has a string s of lowercase letters, where each letter represents a scent vial to be poured, in some order, into a blending flask. Some scent vials are identical (repeated letters).

Find every distinct order in which the vials could have been poured, given that pouring vials of the same scent in different orders relative to each other produces an indistinguishable result.

The resulting list of distinct pouring orders must be sorted in lexicographically increasing order.

Input

A single line containing the string KaTeX can only parse string typed expression.

Output

Print a single integer on the first line — the number of distinct pouring orders. Then print that many lines, each containing one distinct order, sorted lexicographically.

Example
Example 1:
Input
aab
Output
3

aab
aba
baa
Explanation
The vials "aab" can be poured in 3 distinguishable orders (out of 3! = 6 total orderings, since the two 'a' vials are indistinguishable from each other): aab, aba, and baa, listed in sorted order.

Example 2:
Input
a
Output
1

a
Explanation
A single vial has only one possible pouring order.

Online