Roman likes magic and mathematics. The last time he cast a spell with three-digit or four-digit numbers like this:

- from a given number, he created two new numbers by splitting it between the hundreds and tens digits (for example, from the number 581, he would get 5 and 81),
- he added the new numbers and wrote down the result (in the given example, he would get 86),
- he subtracted the smaller of the new numbers from the larger one and wrote the result after the previous sum, thus casting the resulting number (in the given example, he would get 8676).

From which numbers could Roman have cast a) 171, b) 1513? Determine all possibilities.

What is the largest number that can be cast this way, and from which numbers can it arise? Determine all possibilities.

(M. Dillingerová)

Hint. What role do zeros play in Roman's numbers?
After dividing the original number, Roman had two at most two-digit numbers. Their sum can therefore be a one-digit, two-digit, or three-digit number. Their difference can be 0, a one-digit, or a two-digit number. Moreover, the sum is always greater than the difference.

The number 171 could only be obtained by Roman if the sum of the numbers after dividing the original number was 17 and the difference was 1. That is, he added and subtracted the numbers 9 and 8. The number 171 could be conjured by Roman either from the number 908 or from the number 809.

The number 1513 could be obtained by Roman in two ways:

- The sum of the numbers after dividing the original number was 15 and the difference was 13. That is, he added and subtracted the numbers 14 and 1.
- The sum of the numbers after dividing the original number was 151 and the difference was 3. That is, he added and subtracted the numbers 77 and 74.

The number 1513 could be conjured by Roman from one of the numbers 1401, 114, 7774, or 7477.

The resulting number is at least two-digit and at most five-digit. A five-digit number is formed by combining a three-digit sum and a two-digit difference of a pair of numbers after dividing the original number. To make the resulting number the largest possible, the auxiliary sum must be the largest possible, and thus the difference must be the smallest possible (but two-digit). These requirements define the pair 99 and 89: $99+89=188$ and $99-89=10$, the resulting number is 18810, and it can be conjured either from the number 9989 or from the number 8999.