Max Possible

1

1 votes
Easy
Problem

Problem Statement

Given a number N find the smallest and the largest number that can be made using the combinations of the digits.

Input

Input begins with an integer T, the number of numbers that need tweaking. Each of the next T lines contains an integer N.

Output

For the ith number, print a line containing the smallest and largest numbers that can be made from the original number N.

Constraints

1 ≤ T ≤ 100 
0 ≤ N ≤ 999999999 
N will never begin with a leading 0 unless N = 0

Time Limit: 0.2
Memory Limit: 1
Source Limit:
Editor Image

?