Question
Trios Sequence Calculation

In a mystical land, there exists a special sequence called the Trios Sequence, where each number is determined by a magical formula. The formula to find the next number in the sequence is:
Next = Current + maxDigit(Current) * minDigit(Current)
Here, maxDigit(Current) represents the highest digit in the current number, and minDigit(Current) represents the lowest digit.
You are given the first number in the sequence, F1, and a number N that indicates how far into the sequence you need to go. Your task is to determine the value of the Nth number in the Trios Sequence.

Input
The first line of the input contains two space-separated integers F1 and N.

Constraints:
1 ≤ N ≤ 1018
1 ≤ F1 ≤ 1018
Output
Print the value of FN.
Example
Sample Input
1 4
Sample Output
42
Explanation
The number of the sequence is 1.
The second number will be = 1 + maxDigit(1) * minDigit(1) = 1 + 1 * 1 = 2
The third number will be = 2 + maxDigit(2) * minDigit(2) = 2 + 2 * 2 = 6
Similarly the fourth number will be = 6 + 6 * 6 = 42

Sample Input
10 4
Sample Output
10
Explanation
The number of the sequence is 10.
The second number will be = 10 + maxDigit(10) * minDigit(10) = 10 + 1 * 0 = 10
Similarly, third and fourth number will also be 10 and 10.

Online