Description
A palindromic number is a number that remains the same when its digits are reversed.
Like 16461, for example, it is "symmetrical".
Now Krolia want to know the Kth-largest palindromic number which is smaller than n.
Input
There is only one integer T(T<=100) in the first line, indicating the number of test cases.
Every test cases contains two integers n(0<=n<=10^100),k(1<=k<=100).
Output
For every test cases, just output a the kth-largest palindromic number in one line.
If this number doesn't exist, output -1.
Sample Input
5
10 1
1 1
1 2
100 1
112 2
Sample Output
9
0
-1
99
101
Source
KroliaFansClub
这是一道关于数论的题目 题目要求给定一个0<=n<=10^100之间的数n及k ,求小于此数的第K大对称数(比如16461)