#t44. 三位黑洞数

三位黑洞数

The 3-Digit Kaprekar Number

Problem Description

A "black hole number" (also called a trap number, or the "Kaprekar problem") is a class of numbers with a peculiar transform property. Any three-digit number whose digits are not all the same will, after a finite number of "rearrange and subtract" operations, always reach 495495. The resulting 495495 is the 3-digit black hole number. The so-called "rearrange and subtract" operation means: form the largest number and the smallest number obtainable by rearranging the digits of the number, and subtract the smallest from the largest. (61746174 is the 4-digit black hole number.)

For example, for the three-digit number 207207:

1st rearrange-and-subtract: 720−27=693720 - 27 = 693; 2nd: 963−369=594963 - 369 = 594; 3rd: 954−459=495954 - 459 = 495; after that it stays at the black hole number 495495. If the three digits of a three-digit number are all the same, one transform gives 00.

Given any three-digit number, write a program that outputs the rearrange-and-subtract process.

Input Format

The input gives one three-digit number on one line.

Output Format

Output the rearrange-and-subtract process in the following format:

index: largest number after rearrangement - smallest number after rearrangement = difference

The index starts from 11 and continues until 495495 appears on the right side of the equals sign.

Sample Input

123

Sample Output

1: 321 - 123 = 198
2: 981 - 189 = 792
3: 972 - 279 = 693
4: 963 - 369 = 594
5: 954 - 459 = 495

Sample Explanation

The input three-digit number is 123123. First, rearrange the digits 1,2,31, 2, 3 into the largest number 321321 and the smallest number 123123, subtract to get 198198. Then repeat the operation on 198198: rearrange into the largest number 981981 and smallest 189189, subtract to get 792792. Continuing, we get 693,594693, 594, and finally 495495, and the process ends.

Constraints

The input three-digit number satisfies 100≤n≤999100 \le n \le 999.