Do the previous exercise, but now make sure that all anagrams are unique, even if the word contains repetitions of letters. For example, if the word is "bee", you produce "bee", "ebe", and "eeb".