MAX_NUM - finding maximum possible number

no tags 

Given a number n, Find out what max possible number you can make by deleting exactly k digits.

T : no of test cases <= 10^3

1 <= no of digits in n <= 10^5. (n might contain leading zeros)

0 <= k <= n

if value of n is equal to k. then just print a new line.

Input

T: no of test cases

T line follow

every line has

n , k

Output

max possible number

Example

Input:
2
1223 2
8756 2
Output:
23
87
Explanation:

Note that left to right order should be maintained. As in the example given answer is 23 not 32.


hide comments
Robert Gerbicz: 2013-05-02 06:48:14

I feel that we are talking about different problem. What is the answer for: 313 1 ? My current code prints 33.

Robert Gerbicz: 2013-05-02 06:48:14

Any input where my code fails?
ps. The input seems a little broken there are tests where there is a leading zero (though in the maximal number it seems there is no leading zero).

Pranay: 2013-05-02 06:48:14

why can't the resulting number be 32 here ? should the ordering be preserved ?

Last edit: 2013-02-09 15:01:37

Added by:praveen123
Date:2013-02-09
Time limit:0.407s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:general