HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Algorithms and Data Structures > problem:


22. Creating Strings

Volume problems

• 13. Repetitions
• 14. Increasing Array
• 15. Bit Strings
• 16. Josephus Queries
• 18. Apartments
• 19. Ferris Wheel
• 20. Two Sets
• 21. Distinct Numbers
• 22. Creating Strings
• 24. Coin Piles
• 27. Dice Combinations
• 28. Minimizing Coins
• 30. Distinct Numbers
• 31. Apartments
• 32. Ferris Wheel
• 33. Concert Tickets
• 34. Maximum Subarray Sum

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Difficulty Alpha


Given a string, your task is to generate all different strings that can be created using its characters.

Input

The only input line has a string of length n. Each character is between a–z.

Output

First print an integer k: the number of strings. Then print k lines: the strings in alphabetical order.

Constraints

1≤n≤8

Example
Input:
aabac

Output:
20
aaabc
aaacb
aabac
aabca
aacab
aacba
abaac
abaca
abcaa
acaab
acaba
acbaa
baaac
baaca
bacaa
bcaaa
caaab
caaba
cabaa
cbaaa

Для отправки решений необходимо выполнить вход.

www.contester.ru