MAX_NUM - finding maximum possible number

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

T : number of test cases <= 10^3.

1 <= number 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: number of test cases.

T lines follow each with n and 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.


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

hide comments
2014-01-31 14:28:25 Gaara
yipee... AC on my first attempt :D
2013-12-26 20:52:33 Meraj Ahmed
@praveen: could you please look into my solution, I am doing it in O(n) and still getting TLE for judge 3.

solution id: 10744381

Last edit: 2013-12-26 20:53:33
2013-12-11 11:22:59 BA_AK
If the answer contains leaning zeros, should we print them or omit them?
2013-10-25 19:05:44 Achmet ibn Rashid
AC on first try :-) easy problem.
2013-07-06 16:27:31 achiever202
@praveen123

my solution seems fine, i hav tried lots of test cases, bt i am getting WA... please, where am i going wrong...??

my solution code is 9614439
2013-06-15 05:30:37 darryl
@Rajarshi Saha its 045. Print all numbers that are not deleted in the same order as stated.
2013-06-05 14:25:45 Rajarshi Saha
@praveen123 can you tell me what should be the output for 0045 1? Shall it be 005 or 045; not clear about this.
2013-06-01 15:15:24 Ankur
Finally.. AC :)
Awesome problem !!
2013-06-01 12:50:16 Aditya Bahuguna
This gave me immense joy!!!AC
2013-05-29 19:07:56 CKA
<snip>
i suppose solution should time out .but why its giving WA
please help

Last edit: 2022-08-09 23:09:37
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.