#C11147. Smallest Lexicographical Order
Smallest Lexicographical Order
Smallest Lexicographical Order
You are given T test cases. Each test case consists of two integers N and K followed by N identifiers. Although K represents the number of allowed swaps, you can achieve the smallest lexicographical order of each identifier by simply sorting its characters.
More formally, for an identifier \( s \), the desired output is \( \text{sort}(s) \), where \( \text{sort}(s) \) denotes the permutation of characters in s sorted in ascending order.
Your task is to read the input from stdin and, for each test case, output the sorted identifiers in order on one line separated by a single space to stdout.
inputFormat
The first line contains an integer T denoting the number of test cases. For each test case:
- The first line contains two integers N and K (the number of identifiers and the allowed swaps respectively).
- Each of the next N lines contains a single string (an identifier).
Note: The integer K is provided but not used in processing, as the optimal solution is achieved by sorting each identifier.
outputFormat
For each test case, output a single line containing the sorted identifiers (i.e. the smallest lexicographical orders), separated by a space.
## sample2
3 2
abc
bca
cab
2 1
dcba
bacd
abc abc abc
abcd abcd
</p>