You have tasks to do, and workers that can do them. For each task and each worker , is the price that the worker does the task .
Write a program that computes the minimal price of assigning exactly one different task to each worker.
Input consists of a natural , followed by , the matrix of prices ( lines with natural numbers between 1 and 1000).
Your program must print the minimal price of assigning exactly one different task to each worker.
There are algorithms of polynomial cost to solve this problem, but are difficult to program. Implement a backtracking.
Input
3 5 2 1 2 1 3 1 3 7
Output
3
Input
4 2 5 7 9 2 2 2 2 2 1 8 3 2 9 9 8
Output
12