Traveling Salesman Tour 2

No attempts yetTime limit2sMemory limit256 MB

Problem

The traveling salesman problem, TSP for short, is one of the most important problems in computer science. Several variants of it exist. This task uses the most common form.

Cities are numbered 1 through NN, and roads run between cities. Some pairs of cities have no road. A salesman wants to plan a tour that starts at one city, passes through all NN cities, and returns to the city he started from. He may not go back to a city he has already visited. Returning to the starting city at the very end is the only exception. Many such tours exist, and he wants the plan with the smallest total cost.

The cost of moving between cities is given as a matrix WW. W[i][j]W[i][j] is the cost of going from city ii to city jj. The costs are not symmetric, so W[i][j]W[i][j] may differ from W[j][i]W[j][i]. Every travel cost is a positive integer, and W[i][i]W[i][i] is always 0. There are cases where city jj cannot be reached from city ii, and such a case is written as W[i][j]=0W[i][j] = 0.

Given NN and the cost matrix, write a program that finds the minimum cost of the salesman's tour.

Input

The first line contains the number of cities NN. (2N102 \le N \le 10) Each of the next NN lines contains NN entries of the cost matrix. Each entry is a positive integer no greater than 1,000,000, and 0 is given when the move is impossible. W[i][j]W[i][j] is the cost of going from city ii to city jj.

Every input allows at least one tour.

Output

Print the minimum cost of the salesman's tour on the first line.