Largest number in K swaps
Submissions: 6114   Accuracy:

23.96%

  Difficulty: Medium   Marks: 4
Associated Course(s):   Interview Preparation
     

Given a number K and string S of digits denoting a positive integer, build the largest number possible by performing swap operations on the digits of S atmost K times.

Input
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. 
The first line of each test case contains a positive integer K.
The second line of each test case contains a string of digits denoting a positive integer.


Output
Print out the largest number possible.


Constraints
1 <= T <= 100
0 <   S <= 30
0 <   K  <= 10

Examples 

Input
3
4
1234567
3
3435335
2
1034

Output
7654321
5543333
4301

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Rohan Malhotra


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.