13939 - I2P(II) 2023_Yang_final_Bonus   

Description

There are N licenses. Each license has a four-digit integer, where each digit is between 1 and 9. For example, if N=7, the input may look like

7

1324

5566

3578

4123

5656

4312

9847

We want to get the licenses that use the same digits and the digits should be sorted from small to large. For example, 1324, 4123, and 4312 are the combination of the same digits (1, 2, 3, and 4). We want to get 1234. Similarly, 5566 and 5656 are the combination of the same digits (5, 5, 6, and 6). We want to get 5566. 

For output, we list the modified licenses in an increasing order line by line, so the output will look 

1234

5566

 

Input

The first line contains a number N (1<=N<=100).

The next N lines provide the N four-digit integers.

Output

Each line shows a modified unique integer as explained in the problem description.

Remember to print a newline at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss