You are given a string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters, and an integer $$$k$$$. In one step you can perform any one of the two operations below:
You can make as many steps as you want (possibly, zero). Your task is to find the lexicographically smallest string you can obtain after some number of steps.
A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ of the same length if and only if the following holds:
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k < n \le 10^5$$$).
The second line of each test case contains the string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.
For each test case, print the lexicographically smallest string after doing some (possibly, zero) steps.
54 2nima5 3panda9 2theforces7 3amirfar6 4rounds
aimn aandp ceefhorst aafmirr dnorsu
In the first test case, we can obtain the string "aimn" using the following operations:
It can be proven that we cannot obtain any string lexicographically smaller than "aimn". Therefore, "aimn" is the answer.
In the second test case, we can obtain the string "aandp" using the following operations:
It can be proven that we cannot obtain any string lexicographically smaller than "aandp". Therefore, "aandp" is the answer.
Name |
---|