|
digits-1
We call two (positive) numbers friends if the sum of their digits is
equal. For example, the following numbers are all friends with each
other:
3,12,21,30,102,111,120,201,210 Considering, for instance,
111: among numbers smaller than it, its closest friend is 102; among
numbers larger than it, the closest friend is 120. We want to determine
these closest friends for various numbers. That is: given
,
find the largest possible
and smallest possible
such that
,
and both
and
have the same digit sum as
.
Input specification
The first line contains a single integer
:
the number of test cases. Then
lines follow, each containing a number
.
Output specification
Output
lines, each containing the requested
and
numbers. If for a given
there is no
or
,
output
in the corresponding position.
Constraints
Sample input 1
510273837412312312311000
download as text file
Sample output 1
1 100-1 11738365 738383123123114 12312313210100 20000
download as text file
|
|