An $N \times N$ matrix is given. Choose exactly one entry from every row and every column (no two chosen entries share a row or a column). Print the minimum possible sum of the chosen entries.
Input
Line 1: $N$ ($1 \le N \le 10$). Next $N$ lines: $N$ integers each ($1 \le$ value $\le 100$).
Output
Print the minimum selectable sum.
Example 1
Input
3 1 2 5 2 4 3 5 4 3
Output
7
Example 2
Input
2 10 20 30 40
Output
50
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.