Anagram

No attempts yetTime limit1sMemory limit128 MB

Problem

An anagram program prints every distinct word that can be formed by rearranging the letters of a given word. For example, given abc, it prints abc, acb, bac, bca, cab, cba.

A word may contain repeated letters, so the same string can be formed more than once; print each distinct string only once. For each word, print its anagrams in alphabetical (lexicographic) order.

Input

The first line contains the number of words $N$. Each of the next $N$ lines contains one word made only of lowercase English letters. Every word has length at most 20, and only words whose number of distinct anagrams is at most 100,000 are given.

Output

For each word, print all of its anagrams, one per line, in lexicographic order with duplicates removed.