2. An eight-digit natural number $A$, written in the decimal system, is obtained from the number $B$ by swapping the last digit to the first place. It is known that the number $B$ is coprime with the number 36 and $B>77777777$. Find the largest and smallest of the numbers $A$ that satisfy these conditions. (Two natural numbers are called coprime if they have no common divisors other than one). (8 points)
Solution. It is obvious that the last digit of the number $B$ cannot be zero, since when rearranged, it becomes the first digit of the number $A$. In the prime factorization of 36, only the numbers 2 and 3 are present, so the number $B$ will be coprime with 36 if and only if it is not divisible by 2 or 3.

If $b-$ is the last digit of the number $B$, then the number $A=10^{7} \cdot b+1 / 10 \cdot(B-b)$ (it is clear that $B-b$ is divisible by 10).

Obviously, the larger the last digit of the number $B$, the larger the corresponding number $A$. To make $A$ the largest, it is necessary for the last digit of the number $B$ to take the largest possible value, i.e., $b=9$.

If $B^{\prime}$ and $B$ end in 9 and $B^{\prime}>B$, then

$$
\begin{gathered}
A^{\prime}=b^{\prime} \cdot 10^{7}+1 / 10 \cdot\left(B^{\prime}-b^{\prime}\right)>b^{\prime} \cdot 10^{7} \geq(b+1) \cdot 10^{7}= \\
=b \cdot 10^{7}+10^{7}>\mathrm{b} \cdot 10^{7}+1 / 10 \cdot(B-b)=A
\end{gathered}
$$

This means that the larger the number $B$, the larger the corresponding number $A$ (for numbers $B$ ending in 9).

The largest possible value of $B$ is 99999999. This number is not divisible by 2, but it is divisible by 3. By reducing the second-to-last digit by 1, we get $B=999999989$. This number satisfies all conditions: it ends in 9, is coprime with 36, and is the largest among all such numbers. Therefore, it corresponds to the largest possible number $A_{\max }=99999998$.

Similarly, the smallest number is determined: the first digit of $A$ (i.e., the last digit of $B$) should be the smallest possible, so $b=1$. Among the numbers $B$ ending in 1, the smallest $A$ corresponds to the smallest $B$. If the last digit is 1, the smallest number that satisfies the inequality $B>77777777$ is 77777781. But it is divisible by 3, since the sum of the digits is 51. By changing the second-to-last digit to 1, we get the number $B=77777791$, which satisfies all conditions: it ends in 1, is coprime with 36, and is the smallest among all such numbers. It corresponds to the smallest possible number $A_{\min }=17777779$.

Answer. $A_{\min }=17777779, A_{\max }=99999998$