Programming Problem #5
"Fun with Numbers"

The input consists of a single line containing one or more positive integers separated by spaces. No integer will be larger than 1000000000. For each input integer n, find all pairs of positive integers (a,b) such that
  1. a-b=n, and
  2. together a and b have ten digits and use all of the digits between 0 and 9 exactly once.
Numbers cannot have leading zeros. All solutions for a particular value of n must be consecutive and in increasing order with respect to a. The output must be formatted exactly as shown below. Note that numbers are right-justified in a field of width 9, and there is a space on each side of the "-" and "=" symbols. Also note the output in case that an input integer has no pairs (a,b) satisfying the specification.

Input must be read from the file "prob5.in", and output must be written to the file "prob5.out". All output to the screen will be ignored.


Example Input

<BOF>
3312 4
<EOF>

Example Output

    23058 -     19746 =      3312
    30159 -     26847 =      3312
    30861 -     27549 =      3312
    40581 -     37269 =      3312
    41607 -     38295 =      3312
    50139 -     46827 =      3312
    50283 -     46971 =      3312
    53028 -     49716 =      3312
    53172 -     49860 =      3312
    61704 -     58392 =      3312
    62730 -     59418 =      3312
    72450 -     69138 =      3312
    73152 -     69840 =      3312
    80253 -     76941 =      3312
????????? - ????????? =         4

A version of this problem originally appeared in the 1986 North Central Regionals.

Dr. Eric Shade