Sources of Power

All submissions for this problem are available.
While having the tea WonderKing and WonderMath was
talking about sources in the world natural sources like sun, rain. Then again petroleum sources. King was saying whole run on these sources, then the professor WonderMath said dear friend not only us humans, even numbers has their own magical sources, king was amazed and professor was
explaining more like following.
Every number has its own Magical Source. We represent Magical Source
by M and the number by P. M is a magical source of a number P, If the sum of a
sequence of n numbers where the ith number is m x 10i is equal to P.
Consider following examples.
S is regarded as a “ Lucky Set “ because they are going to be released for sure, an integer interval [ A, B ] where A is smaller than B, and A and B are positive integers is considered “ Unlucky “ if none of the integers between A and B, inclusive belongs to the Lucky Set. Largest unlucky interval containing prisoner numbered X will be imprisoned for whole life time. Your program
should find the largest unlucky interval containing the given integer X.
1234 x 10^{0} = 1234
1234 x 10^{1} = 12340
1234 x 10^{2} = 123400
1234 x 10^{3} = 1234000
1234 x 10^{4} = 12340000
1234 + 12340 + 123400 + 1234000 + 12340000 = 13710974
So 1234 is a Magical Source of 13710974
Similar to above example,
99 + 990 + 9900 + 99000 = 109989
Magical Source of 108889 is 99.
Note by this definition, a positive number is a Magical Source of
itself. After such a long explanation WonderMath gave a challenge to his
friend WonderKing. I am giving you set of numbers you must have their
smallest magical source by tomorrow morning. King loved these kinds of
challenges, but this is a big task, will you help him to find
the smallest magical source of a given number and to win his challenge?
happy appyhay
question estionquay
another anotherway
about aboutway
>
happy appyhay
question estionquay
another anotherway
about aboutway
>
Input
Input file, the first line is number of cases ( < 10) and then followed by
numbers P ( < 10^{10}) that you need to find the Magical Source.
Output
The Magical Source of each number.
Constraints 100 <= N <= 999
 100 <= N <= 999
Example
Sample Input:3 13710974 109989 28416
Sample Output:1234 99 256
Explanation
Explained in the above section.
Author:  malin8a 
Tags  malin8a 
Date Added:  27092013 
Time Limit:  0.2432 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 