5. Natural numbers $a, b$ and $c$ are pairwise coprime. The sequence of numbers $a, 2a, 3a, \ldots, b, 2b, 3b, \ldots, c, 2c, 3c, \ldots$ is ordered in ascending order. A new finite sequence is then constructed from the ordered sequence, consisting of ones and twos according to the following rule. Instead of a number that appears once in the sequence, a 1 is written, and instead of a pair of identical numbers, a 2 is written. When three identical numbers are encountered, the process stops. For example, for the numbers $2, 3, 5$, the sequence 111121122121221121111 is constructed. Find the numbers $a, b, c$, if the sequence constructed from them consists of 356 ones and 36 twos and its beginning looks like this: $11111111111111112 \ldots$
1.I.5. Let $a<b<c$ be the desired numbers. We should consider all numbers less than $abc$. Among them, there are $bc-1$ numbers divisible by $a$, $ac-1$ numbers divisible by $b$, and $ab-1$ numbers divisible by $c$. Thus,

$$
bc-1+ac-1+ab-1=356+2 \cdot 36, \text{ or } ab+bc+ac=431.
$$

Similarly, there are $c-1$ numbers divisible by $ab$, $b-1$ numbers divisible by $ac$, and $a-1$ numbers divisible by $bc$, thus,

$$
c-1+b-1+c-1=36, \text{ or } a+b+c=39.
$$

Finally, at the beginning of the sequence, the first "two" corresponds to the number $ab$, and the ones following it correspond to $b-1$ numbers divisible by $a$, $a-1$ numbers divisible by $b$, and $\left[\frac{ab}{c}\right]$ numbers divisible by $c$. Therefore,

$$
b-1+a-1+\left[\frac{ab}{c}\right]=16, \text{ or } a+b+\left[\frac{ab}{c}\right]=18.
$$

Thus, we have the system of equations

$$
\left\{\begin{array}{l}
ab+bc+ac=431 \\
a+b+c=39 \\
a+b+\left[\frac{ab}{c}\right]=18
\end{array}\right.
$$

Adding the fractional part $\left\{\frac{ab}{c}\right\}$ of the number $\frac{ab}{c}$ to both sides of the last equation and multiplying them by $c$, we get the equation

$$
ac+bc+ab=c\left(18+\left\{\frac{ab}{c}\right\}\right)
$$

therefore,

$$
c\left(18+\left\{\frac{ab}{c}\right\}\right)=431, \text{ hence } \frac{431}{19}<c<\frac{431}{18}.
$$

Thus, $c=23$. Solving the remaining equations, we get $a=7$ and $b=9$.