K-Magic Number
Time Limit: 1 Second Memory Limit: 32768 KB
Being given the positive integer 1 < K <= 10^4 you are to find a minimal positive integer N such that if you get the N's first (major) decimal digit away and append it to the end of the rest of N's decimal representation you will get an integer, which is K times less than N.
This problem contains multiple test cases!
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between output blocks.
Input
The input consists of single line that contains single positive integer - K.
Output
Output should contain a single line that contains single positive integer -
N.
Sample Input
1 4
Sample Output
102564Submit