Maximum number
Given a table of size N×N filled with digits, your task is to select N 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 4307 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 N (2 ≤ N ≤ 100). Following this, there are N lines, each containing N digits with no spaces or separators. The digits range from 0 to 9.
Output
Output the maximum number that can be formed from the table. Ensure that leading zeros are not omitted (refer to example #2).