Time limit
2s
Memory limit
128 MB
For a nonnegative integer, define its reversal as the integer obtained by reading its decimal digits from right to left. Any zeros that become leading zeros after the reversal disappear when the value is interpreted as an integer.
Given a natural number D, find the smallest nonnegative integer x such that x - reverse(x) = D. Here, reverse(x) denotes the reversal of x.
D is given. D is a natural number not greater than 1,000,000.
Print the smallest x satisfying the condition. If no such x exists, print -1.