#P2821. 变幻数

变幻数

Description

Given a positive decimal integer nn, its recursive "transform number" is defined as follows:

  • If nn has more than 1 digit (ignoring leading zeros), multiply all its digits, and let the product be mm. Call mm a "sub-transform number" of nn, and call nn a "parent transform number" of mm. To compute the "transform number" of a number means to keep taking its sub-transform number recursively. That is, computing the transform number of nn is the same as computing the transform number of mm.

  • If nn has exactly one digit, then its transform number is itself. For example, the process for the transform number of 679679 is: $679 \to 378(6 \times 7 \times 9) \to 168(3 \times 7 \times 8) \to 48(1 \times 6 \times 8) \to 32(4 \times 8) \to 6(2 \times 3)$, so the transform number of 679679 is 66.

Now, given a sub-transform number kk, what is the smallest parent transform number of kk? For example, when k=18k=18, the parent transform number can be 2929 or 9292, but the smallest is 2929.

Input Format

A sub-transform number kk (number of digits 1000\le 1000).

Output Format

The smallest parent transform number of kk. If no parent transform number exists, output There is no such number!.

48
68

Hint

Translated by ChatGPT 5