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
2013-05-02 06:48:14 praveen123
@Anand Patil: try some numbers ending with zero

Last edit: 2013-02-19 20:44:05
2013-05-02 06:48:14 Anand Patil
@praveen123: can u plz provide the hint on WA for code id - 8744696
2013-05-02 06:48:14 praveen123
@ Nipun : Read constraints again.
I assure you that if your algorithm is correct , then there won't be any tricky test case as such.
2013-05-02 06:48:14 praveen123
@ Aditya : It is expected to TLE
2013-05-02 06:48:14 Nipun Poddar
what will be output for testcase-
45 2
45 3
45 45
0 1
0 0
according to me it should be-
\n
\n
\n
\n
0
please correct me if i am wrong !!

Last edit: 2013-02-17 09:00:47
2013-05-02 06:48:14 Aditya Pande
my O(n^2) gives TLE

Last edit: 2013-02-17 06:18:01
2013-05-02 06:48:14 Nnavneetsinha
@praveen123 Thanks a lot !! I got AC .Very nice problem.
2013-05-02 06:48:14 praveen123
@Nnavneetsinha : You are not satisfying condition of deleting exactly k characters. Try some small test cases.
For the most of the test cases , your code is correct
2013-05-02 06:48:14 Nnavneetsinha
Hey,can you check my code . Id is 8715716.Please provide a hint ,to find the bug.
2013-05-02 06:48:14 praveen123
@ Gaurav : Try writing a brute force checker, You will surely find out your error.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.