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
2020-12-22 17:12:27
Hello you tell me a test that my code gives an error.please
<snip>

[NG]: Read the footer.

Last edit: 2020-12-22 22:16:04
2020-04-04 21:42:19
output leading zeros
ex)
Input:
1
01 0
output:
01
2018-06-24 14:55:45
@praveen123:hi! can u pls tell me where i m lacking in my code 21889739
2016-11-16 12:18:47 sameer Hussain
I am getting TLE, if I use segment tree, for finding out next maximum character.

Can you please tell me where I going wrong here.??

2015-09-01 17:23:12
how can i avoid tle? (15041280)
http://www.spoj.com/status/hazem_khaled8/#
2015-05-26 08:17:31 CoNtRaDiCtIoN
@praveen123 lots of wa can u pls provide some test cases where my solution fails or u can look into my code and tell the probable bugs... Thanks in advance :)
2014-12-20 21:12:39 sahil hindwani
submission id :13224845 why is it giving wrong answer
can any one plsss provide me with the test cases at which my code is failing
2014-12-11 19:09:07 Sudharsansai
Nice Problem!
2014-10-03 05:49:14 $seraph$
@praveen123: Hi! can u pls tell me where i m lacking in my code 12526342.
2014-05-21 16:42:09 Archangel
@praveen123 I want to know that what is the way to remove k digits? Can k digits be removed from anywhere at random or k consecutive digits are to be removed?
Like for n=313 and k=1 we have 31 if consecutive digits are to be removed but if digits are to be removed at random then answer would be 33.
Please clarify my doubt I am not getting it.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.