~/algor $ cat problems/palindromgacha-qoshish
Adding up to a palindrome
Medium
1000 ms
64 MB
47%
A positive integer $n$ is given. If it is not a palindrome (does not read the same from the left and from the right), we add to it the number written with its digits in reverse order ($87 + 78 = 165$) and repeat this until the number becomes a palindrome. Find the number of additions performed and the resulting palindrome.
Input
One positive integer $n$.
Output
Two integers separated by a space: the number of additions and the palindrome.
Note
$1 \le n \le 10^{4}$
it is guaranteed that there are at most $50$ additions and the numbers obtained do not exceed $10^{18}$
Examples
Input #1
87
Output #1
4 4884
Input #2
121
Output #2
0 121