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
Akhil Rao: 2013-05-02 06:48:14

@praveen123 unable to find why i'm getting WA again and again. please suggest what is wrong with my code. ID- 8705244

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

if u cud tell me that for 313 if k=1 33 is the right ans or 31..pls

Last edit: 2013-02-13 09:19:44
praveen123: 2013-05-02 06:48:14

@shiva bhalla , please try some more cases and test your algorithm , May be a brute force generator for testing might help.

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

@praveen123 unable to find why i'm getting WA again and again. please suggest what is wrong with my code. ID- 8700260

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

@Meraj Ahmed read problem carefully

Meraj Ahmed: 2013-05-02 06:48:14

@praveen123: could you tell me where my solution is failing...it says wrong answer in judge 3. submission id: 8694915

Ehor Nechiporenko: 2013-05-02 06:48:14

@Tjandra, good job! Brilliant optimizing!

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

@Tjandra Satria Gunawan , On your suggestion I have changed the judge and rejudged all the submissions. Now I also feel like that time limit is good enough for java users also.
Glad that you liked the problem.

Last edit: 2013-02-11 06:46:06
(Tjandra Satria Gunawan)(曾毅昆): 2013-05-02 06:48:14

Nice problem :-D could you change the cluster to pyramid? I want to know my program running time more accurately..
EDIT: Thanks

Last edit: 2013-02-11 06:44:58
praveen123: 2013-05-02 06:48:14

@jab tak hai jaan:
I had added an extra line to take your case. Thanks for pointing it out.


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