#C4941. Lexicographically Smallest String

    ID: 48535 Type: Default 1000ms 256MiB

Lexicographically Smallest String

Lexicographically Smallest String

Given a string ( s ) consisting of lowercase English letters, you can perform any sequence of swaps and reversals, effectively rearranging the characters in any order. Your task is to determine the lexicographically smallest string that can be obtained. Essentially, this is equivalent to sorting the characters of the string in increasing order.

For example, if ( s = \texttt{cba} ), then the lexicographically smallest string is ( \texttt{abc} ).

Formally, for two strings ( a = (a_1, a_2, \ldots, a_n) ) and ( b = (b_1, b_2, \ldots, b_n) ), we say ( a ) is lexicographically smaller than ( b ) if there exists an index ( k ) such that ( a_i = b_i ) for all ( i < k ) and ( a_k < b_k ).

inputFormat

The input begins with an integer ( T ) on the first line, representing the number of test cases. Each of the following ( T ) lines contains a single string ( s ) consisting only of lowercase letters.

outputFormat

For each test case, output the lexicographically smallest string that can be obtained from the corresponding input string. Each answer should be printed on a new line.## sample

3
cba
xyz
abba
abc

xyz aabb

</p>