#K57277. Unique Anagrams Generator

    ID: 30385 Type: Default 1000ms 256MiB

Unique Anagrams Generator

Unique Anagrams Generator

This problem requires you to generate all distinct anagrams of a given string. An anagram is any permutation of the characters of the string. Given a string ( s ), output all unique anagrams of ( s ) in lexicographical order, each on a new line.

For example, if ( s = \texttt{abc} ), the output should be:
abc
acb
bac
bca
cab
cba

Please note that the input is read from standard input and the output must be written to standard output. Your solution should be efficient enough to handle strings with duplicate characters without repeating anagrams.

inputFormat

The input consists of a single line containing the string ( s ) whose anagrams are to be generated.

outputFormat

Output all unique anagrams of the string ( s ) in lexicographical order, with each anagram printed on a separate line.## sample

a
a