Maximum number#5526

Maximum number

2 seconds
256 megabytes
Hard

Given a table of size N \times N filled with digits, your task is to select elements such that there is exactly one selected element in each row and each column.

Once selected, these elements will form a number where the first digit comes from the first row, the second digit from the second row, and so forth.

For instance, from the marked digits in the table below, the number is formed:

Your goal is to determine the maximum number that can be constructed in this manner from the given table.

Input

The input begins with an integer (2 \leq N \leq 100). Following this, there are lines, each containing digits with no spaces or separators. The digits range from to .

Output

Output the maximum number that can be formed from the table. Ensure that leading zeros are not omitted (refer to example #2).

Examples

Example 1

Loading
Loading