Algorithm of palindromes operation.