Write a program that generates all possible unique words from a given set of letters.
For example, from the word , all possible permutations of the letters are: , , , , , and .
Input words may contain duplicate letters. The program must not output the same word more than once. All words should be printed in ascending alphabetical order.
The first line contains the number of test cases . Each of the following lines contains one word consisting of Latin letters (from to ). Uppercase and lowercase letters are considered different.
For each test case, print all unique words that can be formed from the given letters in ascending alphabetical order. Each word should be printed on a separate line. In alphabetical order, uppercase letters are considered smaller than their lowercase counterparts.
Example 1