The chef has a number N, Cheffina challenges chef to form the largest number X from the digits of N.

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow. 
- Each test case contains a single line of input, $N$. 

-----Output:-----
For each test case, output in a single line answer.

-----Constraints-----
- $1 \leq T \leq 10^5$
- $1 \leq N \leq 10^6$

-----Sample Input:-----
2
2
212

-----Sample Output:-----
2
221

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
n = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
for i in l:
	b = list(map(int, str(i)))
	b.sort(reverse=True)
	s = [str(i) for i in b]
	r = int(''.join(s))
	print(r)


result = []
for i in range(int(input())):
	m = input()
	result.append(''.join(sorted(m, reverse=True)))
for i in range(len(result)):
	print(result[i])


from sys import stdin, stdout
input = stdin.readline
from collections import defaultdict as dd
import math

def geti():
	return list(map(int, input().strip().split()))

def getl():
	return list(map(int, input().strip().split()))

def gets():
	return input()

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')

def solve():
	for _ in range(geta()):
		n = geta()
		a = sorted(list(str(n)), reverse=True)
		print(int(''.join(a)))

def __starting_point():
	solve()
__starting_point()