
46  Andrew Stankevich's Contest, Warmup  1005
Consider integer numbers from 1 to n. Let us call the sum of digits of an integer number its weight. Denote the weight of the number x as w(x). Now let us order the numbers using so called graduated lexicographical ordering, or shorter grlex ordering. Consider two integer numbers a and b. If w(a) < w(b) then a goes before b in grlex ordering. If w(a) = w(b) then a goes before b in grlex ordering if and only if the decimal representation of a is lexicographically smaller than the decimal representation of b. Let us consider some examples.
Given n and some integer number k, find the position of the number k in grlex ordering of integer numbers from 1 to n, and the kth number in this ordering. Input There are several lines in the input file, and each line stands two integers n and k (1 <= k <= n <= 10^{18}). A line with n = k = 0 ends up the input. Output For each line in the input, output one line in the output file. First print the position of the number k in grlex ordering of integer numbers from 1 to n, and then the integer that occupies the kth position in this ordering. Sample Input 20 10 0 0 Sample Output 2 14 Author: Andrew Stankevich 