2. The number $A$ in decimal form is represented as $A=\overline{7 a 631 b}$, where $a, b$ are non-zero digits. The number $B$ is obtained by summing all distinct six-digit numbers, including $A$, that are formed by cyclic permutations of the digits of $A$ (the first digit moves to the second position, the second to the third, and so on, with the last digit moving to the first position). How many numbers $A$ exist such that $B$ is divisible by 121? Find the largest such $A$.
2. Solution. The sum of the digits of number $A$ and the numbers obtained from $A$ by cyclic permutations of its digits is $a+b+17$. After summing these numbers (there are 6 of them), in each digit place of number $B$ we get

$a+b+17$, so $B=(a+b+17)\left(10^{5}+10^{4}+10^{3}+10^{2}+10+1\right)=(a+b+17) \cdot 111111$. Since

$111111=3 \cdot 7 \cdot 11 \cdot 13 \cdot 37$, $B$ is divisible by 121 if and only if $a+b+17$ is divisible by 11. Since $a$ and $b$ are digits, there are only two possible cases: $a+b=5$ and $a+b=16$. From this, we find the possible pairs of $a$ and $b$: $a=1, b=4 ; a=2, b=3 ; a=3, b=2 ; a=4, b=1 ; a=7, b=9 ; a=8, b=8 ; a=9, b=7$. Thus, 7 numbers satisfy the condition of the problem. The largest number is obtained when $a=9, b=7$. It is 796317.