Question 23
For a positive integer $m$ denote by $S(m)$ and $P(m)$ the sum and product, respectively, of the digits of $m$. Show that for each positive integer $n$, there exist positive integers $a_{1}, a_{2}, \ldots, a_{n}$ satisfying the following conditions:
$$
S\left(a_{1}\right)\lt S\left(a_{2}\right)\lt \cdots\lt S\left(a_{n}\right) \text{ and } S\left(a_{i}\right)=P\left(a_{i+1}\right) \quad(i=1,2, \ldots, n) .
$$
(We let $a_{n+1}=a_{1}$.) (Problem Committee of the Japan Mathematical Olympiad Foundation)
$$
S\left(a_{1}\right)\lt S\left(a_{2}\right)\lt \cdots\lt S\left(a_{n}\right) \text{ and } S\left(a_{i}\right)=P\left(a_{i+1}\right) \quad(i=1,2, \ldots, n) .
$$
(We let $a_{n+1}=a_{1}$.) (Problem Committee of the Japan Mathematical Olympiad Foundation)