#K94337. Smallest Unique Permutation

    ID: 38619 Type: Default 1000ms 256MiB

Smallest Unique Permutation

Smallest Unique Permutation

You are given a string s. Your task is to find the lexicographically smallest permutation of s that contains all unique characters from s. In other words, take all distinct characters from s and sort them in increasing order.

If s is empty, output an empty string.

The lexicographical order is defined as usual, i.e., \(a < b < c < \ldots < z\).

inputFormat

The first line contains an integer T which denotes the number of test cases. Each of the following T lines contains a single string s.

outputFormat

For each test case, output the lexicographically smallest permutation of s that consists of all unique characters, with each result on a new line. If s is empty, output an empty line.

## sample
4
google
apple
banana
abcde
eglo

aelp abn abcde

</p>